This commit is contained in:
huang 2015-07-02 08:44:14 +08:00
commit 39eb6a5f7c
14 changed files with 171 additions and 77 deletions

View File

@ -34,13 +34,21 @@ class AdminController < ApplicationController
def projects
@status = params[:status] || 1
scope = Project.status(@status).order('lft')
scope = Project.status(@status).order('id asc')
scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.where(project_type: Project::ProjectType_project).all
render :action => "projects", :layout => false if request.xhr?
end
def courses
@name = params[:name]
@courses = Course.like(@name)
respond_to do |format|
format.html
end
end
def users
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)

View File

@ -443,26 +443,19 @@ class CoursesController < ApplicationController
def create
cs = CoursesService.new
@course = cs.create_course(params,User.current)[:course]
if @course.new_record?
if @course
respond_to do |format|
format.html { render :action => 'new', :layout => 'new_base' } #Added by young
format.api { render_validation_errors(@course) }
flash[:notice] = l(:notice_successful_create)
format.html {redirect_to settings_course_url(@course, :course_type => 1)}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
end
else
respond_to do |format|
format.html {
# render :layout => 'base_courses'
flash[:notice] = l(:notice_successful_create)
if params[:continue]
redirect_to new_course_url(attrs, :course => '0')
elsif params[:course_continue]
redirect_to new_course_url(:course => '1')
else
redirect_to settings_course_url(@course, :course_type => 1)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
end
flash[:notice] = l(:notice_create_failed)
# @course = Course.new
format.html { redirect_to new_course_path } #Added by young
format.api { render_validation_errors(@course) }
end
end
end
@ -532,7 +525,7 @@ class CoursesController < ApplicationController
@trackers = Tracker.sorted.all
@course = Course.new
@course.safe_attributes = params[:course]
month = Time.now.month
# month = Time.now.month
render :layout => 'new_base'
end

View File

@ -37,7 +37,7 @@ class FilesController < ApplicationController
obj.each do |container|
@attachments += container.attachments
end
@all_attachments = visable_attachemnts(@attachments)
@all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']

View File

@ -839,7 +839,7 @@ class Project < ActiveRecord::Base
# Yields the given block for each project with its level in the tree
def self.project_tree(projects, &block)
ancestors = []
projects.sort_by(&:lft).each do |project|
projects.sort_by(&:id).each do |project|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
end

View File

@ -201,12 +201,14 @@ class CoursesService
@course.class_period = params[:class_period].to_i
params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0
params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0
else
end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
if @course.save
if @course && @course.save
#unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => current_user, :roles => [r])

View File

@ -0,0 +1,76 @@
<div class="contextual">
<%= link_to l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
</div>
<h3>
<%=l(:label_course_all)%>
</h3>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<label for='name'>
课程:
</label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<a class="icon icon-reload" onclick="$('#name').val('')" style="cursor: pointer;text-decoration: none;">
<%= l(:button_clear)%>
</a>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 120px;">
课程
</th>
<th style="width: 50px;">
主讲老师
</th>
<th style="width: 30px;">
学时
</th>
<th style="width: 20px;">
<%=l(:field_is_public)%>
</th>
<th style="width: 70px;">
<%=l(:field_created_on)%>
</th>
</tr>
</thead>
<tbody>
<% @courses.each do |course| %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= course.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=course.name%>'>
<span>
<%= link_to(course.name, course_path(course.id)) %>
</span>
</td>
<td align="center">
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
</td>
<td align="center">
<%= course.class_period %>
</td>
<td class="center">
<%= checked_image course.is_public? %>
</td>
<td class="center">
<%= format_date(course.created_at) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_course_all)) -%>

View File

@ -1,5 +1,5 @@
<div class="contextual">
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
</div>
<h3>
@ -7,62 +7,70 @@
</h3>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<legend>
<fieldset>
<legend>
<%= l(:label_filter_plural) %>
</legend>
<label for='status'>
<%= l(:field_status) %> :
</label>
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
<label for='name'>
<%= l(:label_project) %>:
</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
</fieldset>
</legend>
<label for='status'>
<%= l(:field_status) %> :
</label>
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
<label for='name'>
<%= l(:label_project) %>:
</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead><tr>
<th>
<%=l(:label_project)%>
</th>
<th>
<%=l(:field_is_public)%>
</th>
<th>
<%=l(:field_created_on)%>
</th>
<th></th>
</tr></thead>
<tbody>
<% project_tree(@projects) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=project.name%>'>
<span>
<%= link_to_project_settings(project, {}) %>
</span>
</td>
<td align="center">
<%= checked_image project.is_public? %>
</td>
<td align="center">
<%= format_date(project.created_on) %>
</td>
<td class="buttons">
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
</td>
</tr>
<% end %>
</tbody>
</table>
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 120px;">
<%=l(:label_project)%>
</th>
<th style="width: 20px;">
<%=l(:field_is_public)%>
</th>
<th style="width: 30px;">
<%=l(:field_created_on)%>
</th>
<th style="width: 70px;"></th>
</tr>
</thead>
<tbody>
<% project_tree(@projects) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<td style="text-align: center;">
<%= project.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=project.name%>'>
<span>
<%= link_to_project_settings(project, {}) %>
</span>
</td>
<td align="center">
<%= checked_image project.is_public? %>
</td>
<td align="center">
<%= format_date(project.created_on) %>
</td>
<td class="buttons">
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_project_plural)) -%>

View File

@ -22,7 +22,7 @@
<div class="for_img_thumbnails">
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div class="re_con_box" id="container_files_<%= file.id %>">
<div class="">
<%= link_to truncate(file.filename,length: 35, omission: '...'),

View File

@ -69,10 +69,9 @@
<span class="c_red">winrar</span>
工具进行解压
</div>
<%= link_to l(:label_list), student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
<%= link_to "匿评", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr'%>
<%= link_to "缺评", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr'%>
<%= link_to l(:label_list), student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%>
<span class="mt3 fr " style="color:#136b3b;">导出全部:</span>
</div>
<% end%>

View File

@ -25,6 +25,11 @@
:homework => @homework.id
}) do |f|%>
<div class="N_con">
<% if @homework.homework_type == 1%>
<div class=" c_red mb10 ml90">
提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
</div>
<% end%>
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>

View File

@ -263,7 +263,7 @@ zh:
label_tags_numbers: "Tag统计"
label_issue_plural: 问题跟踪
label_project_plural: 项目列表
# label_project_plural: 项目列表
label_user_plural: 用户列表
label_tags_call: 需求
field_filename: 文件

View File

@ -12,6 +12,7 @@ zh:
notice_account_wrong_password: 密码错误
name_can_be_empty: 可以不填写真实姓名[保密所需]
notice_successful_create: 创建成功
notice_create_failed: 创建失败,请先完善个人信息
notice_failed_create: 创建失败
notice_successful_update: 更新成功
notice_successful_edit: 修改成功

View File

@ -635,6 +635,7 @@ RedmineApp::Application.routes.draw do
match 'admin', :to => 'admin#index', :via => :get
match 'admin/projects', :via => :get
get 'admin/courses'
match 'admin/users', :via => :get
match 'admin/first_page_made', as: :first_page_made
match 'admin/course_page_made', as: :course_page_made

View File

@ -367,6 +367,7 @@ end
Redmine::MenuManager.map :admin_menu do |menu|
menu.push :organization, {:controller => 'admin', :action => 'organization'}, :caption => :label_organization_list
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made
menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version