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

View File

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

View File

@ -37,7 +37,7 @@ class FilesController < ApplicationController
obj.each do |container| obj.each do |container|
@attachments += container.attachments @attachments += container.attachments
end end
@all_attachments = visable_attachemnts(@attachments) @all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
@limit = 10 @limit = 10
@feedback_count = @all_attachments.count @feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @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 # Yields the given block for each project with its level in the tree
def self.project_tree(projects, &block) def self.project_tree(projects, &block)
ancestors = [] ancestors = []
projects.sort_by(&:lft).each do |project| projects.sort_by(&:id).each do |project|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop ancestors.pop
end end

View File

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

@ -27,21 +27,29 @@
<div class="autoscroll"> <div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed"> <table class="list" style="width: 100%;table-layout: fixed">
<thead><tr> <thead>
<th> <tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 120px;">
<%=l(:label_project)%> <%=l(:label_project)%>
</th> </th>
<th> <th style="width: 20px;">
<%=l(:field_is_public)%> <%=l(:field_is_public)%>
</th> </th>
<th> <th style="width: 30px;">
<%=l(:field_created_on)%> <%=l(:field_created_on)%>
</th> </th>
<th></th> <th style="width: 70px;"></th>
</tr></thead> </tr>
</thead>
<tbody> <tbody>
<% project_tree(@projects) do |project, level| %> <% project_tree(@projects) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> <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%>'> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=project.name%>'>
<span> <span>
<%= link_to_project_settings(project, {}) %> <%= link_to_project_settings(project, {}) %>

View File

@ -22,7 +22,7 @@
<div class="for_img_thumbnails"> <div class="for_img_thumbnails">
<% curse_attachments.each do |file| %> <% 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="re_con_box" id="container_files_<%= file.id %>">
<div class=""> <div class="">
<%= link_to truncate(file.filename,length: 35, omission: '...'), <%= link_to truncate(file.filename,length: 35, omission: '...'),

View File

@ -69,10 +69,9 @@
<span class="c_red">winrar</span> <span class="c_red">winrar</span>
工具进行解压 工具进行解压
</div> </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 "匿评", 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 "缺评", 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> <span class="mt3 fr " style="color:#136b3b;">导出全部:</span>
</div> </div>
<% end%> <% end%>

View File

@ -25,6 +25,11 @@
:homework => @homework.id :homework => @homework.id
}) do |f|%> }) do |f|%>
<div class="N_con"> <div class="N_con">
<% if @homework.homework_type == 1%>
<div class=" c_red mb10 ml90">
提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
</div>
<% end%>
<p> <p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label> <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();" %> <%= 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_tags_numbers: "Tag统计"
label_issue_plural: 问题跟踪 label_issue_plural: 问题跟踪
label_project_plural: 项目列表 # label_project_plural: 项目列表
label_user_plural: 用户列表 label_user_plural: 用户列表
label_tags_call: 需求 label_tags_call: 需求
field_filename: 文件 field_filename: 文件

View File

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

View File

@ -635,6 +635,7 @@ RedmineApp::Application.routes.draw do
match 'admin', :to => 'admin#index', :via => :get match 'admin', :to => 'admin#index', :via => :get
match 'admin/projects', :via => :get match 'admin/projects', :via => :get
get 'admin/courses'
match 'admin/users', :via => :get match 'admin/users', :via => :get
match 'admin/first_page_made', as: :first_page_made match 'admin/first_page_made', as: :first_page_made
match 'admin/course_page_made', as: :course_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| Redmine::MenuManager.map :admin_menu do |menu|
menu.push :organization, {:controller => 'admin', :action => 'organization'}, :caption => :label_organization_list menu.push :organization, {:controller => 'admin', :action => 'organization'}, :caption => :label_organization_list
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural 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 :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 :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 menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version