From ae5ced6a51d5b16afaaa905950bfd5d68b1b13ce Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 4 Jun 2014 17:39:11 +0800 Subject: [PATCH 01/20] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=88=E9=83=A8=E5=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 19 +++++++++++++++++++ config/settings.yml | 1 + lib/redmine.rb | 24 ++++++++++++++++++------ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9f6fb26c..8d2ccfb5 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -454,6 +454,25 @@ zh: permission_manage_subtasks: 管理子任务 permission_view_journals_for_messages: 查看留言 permission_view_courses: 查看课程列表 + permission_new_course: 新建课程 + permission_configure_course: 配置课程 + permission_close_course: 关闭/重开课程 + permission_new_assignment: 新建任务 + permission_edit_assignment: 编辑任务 + permission_delete_assignment: 删除任务 + permission_new_placeholder: 新建占位 + permission_edit_placeholder: 编辑占位 + permission_delete_placeholder: 删除占位 + permission_commit_content: 提交内容 + permission_new_course_notify: 发布课程通知 + permission_edit_course_notify: 编辑课程通知 + permission_delete_course_notify: 删除课程通知 + permission_view_assignment: 查看任务 + permission_view_placeholder: 查看占位 + permission_view_course_messages: 查看留言 + permission_view_real_name: 查看真名 + + project_module_issue_tracking: 问题跟踪 project_module_time_tracking: 时间跟踪 diff --git a/config/settings.yml b/config/settings.yml index fbaba502..f2c64a97 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -172,6 +172,7 @@ default_projects_modules: - boards - calendar - gantt + - course default_projects_tracker_ids: serialized: true default: diff --git a/lib/redmine.rb b/lib/redmine.rb index 7b83c7cb..5c96ce92 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -179,13 +179,25 @@ Redmine::AccessControl.map do |map| end #课程权限模块 - map.project_module :course do + map.project_module :course do |map| map.permission :view_courses,{:projects => [:course]},:read => true - end - - #作业模块权限 - map.project_module :bids do |map| - map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true + #map.permission :new_course, {}, :read => true + #map.permission :configure_course,{},:read => true + #map.permission :close_course,{},:read => true + map.permission :new_assignment,{:projects => [:new_homework]},:read => true + map.permission :edit_assignment,{:bids => [:edit]},:read => true + map.permission :delete_assignment,{:bids => [:homework_destroy]},:read => true + map.permission :new_placeholder,{:homework_attach => [:new]},:read => true + map.permission :edit_placeholder,{},:read => true + map.permission :delete_placeholder,{},:read => true + map.permission :commit_content,{},:read => true + #map.permission :new_course_notify,{},:read => true + #map.permission :edit_course_notify,{},:read => true + #map.permission :delete_course_notify,{},:read => true + map.permission :view_assignment,{},:read => true + map.permission :view_placeholder,{},:read => true + map.permission :view_course_messages,{},:read => true + map.permission :view_real_name,{},:read => true end map.project_module :boards do |map| From cb03669085596ba2e4c10c08b220754f32b4dbbe Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Jun 2014 15:00:38 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=99=E8=A8=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index bb7a2424..ed6cdd25 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -70,7 +70,12 @@ class Mailer < ActionMailer::Base end mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " - else + elsif journals_for_message.jour.class.to_s.to_sym == :Bid + if !journals_for_message.jour.author.notify_about? journals_for_message + return -1 + end + mail :to => journals_for_message.jour.author.mail, :subject => @title + else mail :to => @mail.mail, :subject => @title end From 1c7923e5bdedff26d45b7002a38455c9bdf7fbd1 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 5 Jun 2014 16:53:41 +0800 Subject: [PATCH 03/20] sql --- app/controllers/bids_controller.rb | 4 +--- app/helpers/bids_helper.rb | 2 +- app/helpers/courses_helper.rb | 2 +- app/models/user.rb | 2 +- app/views/bids/_homework_list.html.erb | 11 +++-------- app/views/layouts/base_homework.html.erb | 4 ++-- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index c0df0699..2ad60fc2 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -410,9 +410,7 @@ class BidsController < ApplicationController @homework = HomeworkAttach.new #@homework_list = @bid.homeworks #增加作业按评分排序, - @homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id) AS score - FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC") + @homework_list = @bid.homeworks.joins(:user).includes(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC') if params[:student_id].present? @temp = [] @homework_list.each do |pro| diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 8b03d74c..40cec6ed 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -158,7 +158,7 @@ module BidsHelper #当前用户是不是指定课程的学生 def is_cur_course_student? course people = [] - course.members.each do |member| + course.members.includes(:user, :roles).each do |member| if [5,10].include? member.roles.first.id people << member.user end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index fb0a269e..f16aef91 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -139,7 +139,7 @@ module CoursesHelper #判断制定用户是不是当前课程的老师 def is_course_teacher user,course people = [] - course.members.each do |member| + course.members.includes(:roles, :user).each do |member| role_id = member.roles.first.id if TeacherRoles.include? role_id people << member.user diff --git a/app/models/user.rb b/app/models/user.rb index d79cf11e..689cc7b2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -137,7 +137,7 @@ class User < Principal has_one :user_extensions,:dependent => :destroy ## end - #default_scope -> { includes(:user_extensions, :user_score) } + default_scope -> { includes(:user_extensions, :user_score) } scope :teacher, -> { joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER) } diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 48f1c150..d2d58753 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -83,13 +83,8 @@ 作业评分: - <% stars_reates = homework.rates(:quality) %> - <% sum = 0 %> - <% stars_reates.each do |star_reates| %> - <% sum = sum + star_reates.stars %> - <% end %> - <% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %> - <%= format("%.2f", sum * 1.0 / stars_reates_count) %> + + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_i ) %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> @@ -100,7 +95,7 @@   <% if User.current.member_of?(@bid.courses.first) %> - <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> + <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.student_id%> <% end %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 81a8b086..8c108ba2 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -18,8 +18,8 @@ <%= yield :header_tags -%> - <% project = @bid.courses.first %> - <% course = Course.find_by_extra(project.identifier) %> + <% project = @bid.courses.includes(:course_extra).first %> + <% course = project.course_extra %>
From bce592ba85d8063335c64152719c30d77d316b38 Mon Sep 17 00:00:00 2001 From: senluo Date: Thu, 5 Jun 2014 17:25:28 +0800 Subject: [PATCH 04/20] A gem who in lib and Gemfile must be have a suitable version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3784e60d..9dae2827 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem "i18n", "~> 0.6.0" gem "coderay", "~> 1.0.6" gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" -gem 'acts-as-taggable-on' +gem 'acts-as-taggable-on', '2.4.1' group :development do gem 'better_errors', path: 'lib/better_errors' From 57994edc0610bb31e10bcb2a162d34d13e23e86e Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 5 Jun 2014 17:29:11 +0800 Subject: [PATCH 05/20] load user in homework --- app/controllers/bids_controller.rb | 2 +- app/views/layouts/base_homework.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 2ad60fc2..8bfab408 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -410,7 +410,7 @@ class BidsController < ApplicationController @homework = HomeworkAttach.new #@homework_list = @bid.homeworks #增加作业按评分排序, - @homework_list = @bid.homeworks.joins(:user).includes(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC') + @homework_list = @bid.homeworks.joins(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC') if params[:student_id].present? @temp = [] @homework_list.each do |pro| diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 8c108ba2..4fbdda1d 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -179,7 +179,7 @@ <% if @bid.homework_type == 1%> <% if @bid.homeworks.size>0 %> - <% for homework in @bid.homeworks %> + <% for homework in @bid.homeworks.eager_load(:user) %> <%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> <% end %> <% else %>

From 0d8b06ec8755ccc5b30fe8ee5c9263db9c2b1699 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 5 Jun 2014 17:32:26 +0800 Subject: [PATCH 06/20] e, bug --- app/controllers/bids_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 8bfab408..ff6fda49 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -410,7 +410,7 @@ class BidsController < ApplicationController @homework = HomeworkAttach.new #@homework_list = @bid.homeworks #增加作业按评分排序, - @homework_list = @bid.homeworks.joins(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC') + @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC') if params[:student_id].present? @temp = [] @homework_list.each do |pro| From d83899e3e401fc11e69255b0a7c6e00dd0c16383 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Jun 2014 17:39:48 +0800 Subject: [PATCH 07/20] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E3=80=81=E7=BC=96=E8=BE=91=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E3=80=81=E5=88=A0=E9=99=A4=E4=BB=BB=E5=8A=A1=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=8D=A0=E4=BD=8D=E3=80=81=E7=BC=96=E8=BE=91=E5=8D=A0?= =?UTF-8?q?=E4=BD=8D=E3=80=81=E5=88=A0=E9=99=A4=E5=8D=A0=E4=BD=8D=E3=80=81?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E4=BB=BB=E5=8A=A1=E3=80=81=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E3=80=81=E6=9F=A5=E7=9C=8B=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BB=A3=E7=A0=81=EF=BC=88=E6=9C=AA=E5=BA=94?= =?UTF-8?q?=E7=94=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 8 +++++++ app/controllers/bids_controller.rb | 17 ++++++++++++++- app/controllers/homework_attach_controller.rb | 18 ++++++++++++++++ app/controllers/projects_controller.rb | 1 + config/locales/en.yml | 21 +++++++++++++++++++ config/locales/zh.yml | 3 ++- lib/redmine.rb | 14 +++++++------ 7 files changed, 74 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a25b346c..4b877818 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -264,6 +264,14 @@ class ApplicationController < ActionController::Base render_404 end + #根据course_id找project + def find_project_by_course_id + @bid = Bid.find params[:course_id] + @project = @bid.courses[0] + rescue ActiveRecord::RecordNotFound + render_404 + end + # Find a project based on params[:project_id] # TODO: some subclasses override this, see about merging their logic def find_optional_project diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index cdf6e7d5..991d347e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -16,6 +16,13 @@ class BidsController < ApplicationController before_filter :memberAccess, only: :show_project + #判断当前角色权限时需先找到当前操作的project + before_filter :find_project_by_project_id, :only => [:edit] + before_filter :find_project_by_course_id, :only => [:homework_destroy] + before_filter :find_project_by_bid_id, :only => [:show_project] + #判断当前角色是否有操作权限 + #勿删 before_filter :authorize, :only => [:edit,:homework_destroy,:show_project] + helper :watchers helper :attachments include AttachmentsHelper @@ -25,7 +32,14 @@ class BidsController < ApplicationController helper :projects helper :words helper :welcome - + + def find_project_by_bid_id + @bid = Bid.find(params[:id]) + @project = @bid.courses[0] + rescue ActiveRecord::RecordNotFound + render_404 + end + def homework_ajax_modal @bid = Bid.find_by_id(params[:id]) # find_bid @@ -523,6 +537,7 @@ class BidsController < ApplicationController message = params[:bid_message][:message] + "\n" + params[:reference_content] else message = params[:bid_message][:message] + @m = message end refer_user_id = params[:bid_message][:reference_user_id].to_i @bid.add_jour(User.current, message, refer_user_id) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 24e1a86e..13ec7a18 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -1,5 +1,23 @@ class HomeworkAttachController < ApplicationController ############################### + #判断当前角色权限时需先找到当前操作的project + before_filter :find_project_by_bid_id, :only => [:new] + before_filter :find_project_by_hoemwork_id, :only => [:edit,:update,:destroy] + #判断当前角色是否有操作权限 + #勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy] + + def find_project_by_bid_id + @bid = Bid.find(params[:id]) + @project = @bid.courses[0] + rescue ActiveRecord::RecordNotFound + render_404 + end + + def find_project_by_hoemwork_id + @homework = HomeworkAttach.find(params[:id]) + @project = @homework.bid.courses[0] + end + def index @homeworks = HomeworkAttach.all respond_to do |format| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 16d9d71d..8d6f5371 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -37,6 +37,7 @@ class ProjectsController < ApplicationController # before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, # :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share, # :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index] + #此条勿删 课程相关权限 ,:new_homework,:homework,:feedback before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] diff --git a/config/locales/en.yml b/config/locales/en.yml index 23911e56..d8bfc966 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -473,6 +473,27 @@ en: permission_export_wiki_pages: Export wiki pages permission_manage_subtasks: Manage subtasks permission_manage_related_issues: Manage related issues + permission_view_journals_for_messages: View journals messages + permission_view_courses: View courses + permission_new_course: Create course + permission_configure_course: Configure course + permission_close_course: Close/open course + permission_new_assignment: Create assignment + permission_edit_assignment: Edit assignment + permission_delete_assignment: Delete assignment + permission_new_placeholder: Create placeholder + permission_edit_placeholder: Edit placeholder + permission_delete_placeholder: Delete placeholder + permission_commit_content: Commit content + permission_new_course_notify: Create course notify + permission_edit_course_notify: Eidt course notify + permission_delete_course_notify: Delete course notify + permission_view_assignment: View assignment + permission_view_placeholder: View placeholder + permission_view_course_messages: View course messages + permission_view_real_name: View real name + permission_view_students: View students + permission_export_homeworks: Export homeworks project_module_issue_tracking: Issue tracking project_module_time_tracking: Time tracking diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 8d2ccfb5..c945bbda 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -471,7 +471,8 @@ zh: permission_view_placeholder: 查看占位 permission_view_course_messages: 查看留言 permission_view_real_name: 查看真名 - + permission_view_students: 查看学生列表 + permission_export_homeworks: 导出作业 project_module_issue_tracking: 问题跟踪 diff --git a/lib/redmine.rb b/lib/redmine.rb index 5c96ce92..33d9bf58 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -188,16 +188,18 @@ Redmine::AccessControl.map do |map| map.permission :edit_assignment,{:bids => [:edit]},:read => true map.permission :delete_assignment,{:bids => [:homework_destroy]},:read => true map.permission :new_placeholder,{:homework_attach => [:new]},:read => true - map.permission :edit_placeholder,{},:read => true - map.permission :delete_placeholder,{},:read => true - map.permission :commit_content,{},:read => true + map.permission :edit_placeholder,{:homework_attach => [:edit,:update]},:read => true + map.permission :delete_placeholder,{:homework_attach => [:destroy]},:read => true + #map.permission :commit_content,{},:read => true #map.permission :new_course_notify,{},:read => true #map.permission :edit_course_notify,{},:read => true #map.permission :delete_course_notify,{},:read => true - map.permission :view_assignment,{},:read => true - map.permission :view_placeholder,{},:read => true - map.permission :view_course_messages,{},:read => true + map.permission :view_assignment,{:projects => [:homework]},:read => true + map.permission :view_placeholder,{:bids => [:show_project]},:read => true + map.permission :view_course_messages,{:projects => [:feedback]},:read => true map.permission :view_real_name,{},:read => true + map.permission :view_students,{}, :read=>true + map.permission :export_homeworks,{},:read => true end map.project_module :boards do |map| From c5fc1a87098e6e6c2db5fc4805fbab5fdb9409f6 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Jun 2014 15:00:38 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=99=E8=A8=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e0ad5429..c5628cf2 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -66,7 +66,12 @@ class Mailer < ActionMailer::Base end mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " - else + elsif journals_for_message.jour.class.to_s.to_sym == :Bid + if !journals_for_message.jour.author.notify_about? journals_for_message + return -1 + end + mail :to => journals_for_message.jour.author.mail, :subject => @title + else mail :to => @mail.mail, :subject => @title end From 174c5556a01afcf6dc63ecc490ada1c2fa490e17 Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 6 Jun 2014 09:26:09 +0800 Subject: [PATCH 09/20] =?UTF-8?q?=E5=87=8F=E5=B0=91sql=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=20logger=20=3D=3D=3D>=20Rails.logger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- app/models/mailer.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f16aef91..5531f3f8 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -150,7 +150,7 @@ module CoursesHelper #当前用户是不是指定课程的学生 def is_cur_course_student? course people = [] - course.members.each do |member| + course.members.includes(:roles, :user).each do |member| if StudentRoles.include? member.roles.first.id people << member.user end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index ed6cdd25..e954f03c 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -51,7 +51,7 @@ class Mailer < ActionMailer::Base when :User user_newfeedback_user_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") else - logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}" + Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}" return -1 end #如果是直接留言并且留言对象是Project并且Project类型是课程 From 4478c86ceae67bb8680b36cd24a6663cb50567d2 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 6 Jun 2014 10:37:06 +0800 Subject: [PATCH 10/20] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8B=20?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E7=9C=9F=E5=90=8D=E3=80=81=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E6=88=90=E5=91=98=E3=80=81=E4=BD=9C=E4=B8=9A=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BB=A3=E7=A0=81=EF=BC=88=E6=9C=AA=E5=BA=94?= =?UTF-8?q?=E7=94=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 2 +- app/controllers/projects_controller.rb | 5 ++++- app/controllers/zipdown_controller.rb | 14 ++++++++++++++ config/locales/zh.yml | 4 ++-- lib/redmine.rb | 6 +++--- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6680070a..e6ee7da7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,7 +134,7 @@ PLATFORMS DEPENDENCIES activerecord-jdbc-adapter (= 1.2.5) activerecord-jdbcmysql-adapter - acts-as-taggable-on + acts-as-taggable-on (= 2.4.1) better_errors! builder (= 3.0.0) coderay (~> 1.0.6) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8d6f5371..ad3dc3dc 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -37,7 +37,7 @@ class ProjectsController < ApplicationController # before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, # :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share, # :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index] - #此条勿删 课程相关权限 ,:new_homework,:homework,:feedback + #此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] @@ -722,6 +722,9 @@ class ProjectsController < ApplicationController @teachers= searchTeacherAndAssistant(@project) @canShowRealName = isCourseTeacher(User.current.id) end + + #勿删 real_name action为虚拟的该方法并不存在,用来辅助判断真名权限 + #勿删 @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false) respond_to do |format| format.html{render :layout => 'base_courses' if @base_courses_tag==1} format.api diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 5caa97a2..ee546080 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -1,7 +1,21 @@ class ZipdownController < ApplicationController + #查找项目(课程) + before_filter :find_project_by_bid_id, :only => [:assort,:download_user_homework] + #检查权限 + #勿删 before_filter :authorize, :only => [:assort,:download_user_homework] SAVE_FOLDER = "#{Rails.root}/files" OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip" + #通过作业Id找到项目(课程) + def find_project_by_bid_id + obj_class = params[:obj_class] + obj_id = params[:obj_id] + obj = obj_class.constantize.find(obj_id) + case obj.class.to_s.to_sym + when :Bid + @project = obj.courses[0] + end + end def assort obj_class = params[:obj_class] obj_id = params[:obj_id] diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 139e8fe9..42886845 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -453,7 +453,7 @@ zh: permission_export_wiki_pages: 导出 wiki 页面 permission_manage_subtasks: 管理子任务 permission_view_journals_for_messages: 查看留言 - permission_view_courses: 查看课程列表 + permission_view_courses: 查看课程 permission_new_course: 新建课程 permission_configure_course: 配置课程 permission_close_course: 关闭/重开课程 @@ -471,7 +471,7 @@ zh: permission_view_placeholder: 查看占位 permission_view_course_messages: 查看留言 permission_view_real_name: 查看真名 - permission_view_students: 查看学生列表 + permission_view_students: 查看成员 permission_export_homeworks: 导出作业 diff --git a/lib/redmine.rb b/lib/redmine.rb index 33d9bf58..7d3aa9ea 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -197,9 +197,9 @@ Redmine::AccessControl.map do |map| map.permission :view_assignment,{:projects => [:homework]},:read => true map.permission :view_placeholder,{:bids => [:show_project]},:read => true map.permission :view_course_messages,{:projects => [:feedback]},:read => true - map.permission :view_real_name,{},:read => true - map.permission :view_students,{}, :read=>true - map.permission :export_homeworks,{},:read => true + map.permission :view_real_name,{:projects => [:real_name]},:read => true + map.permission :view_students,{:projects => [:member]}, :read=>true + map.permission :export_homeworks,{:zipdown => [:assort,:download_user_homework]},:read => true end map.project_module :boards do |map| From cf5c7a66104ebe8ee3292a0a45503957ec0a2b85 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 6 Jun 2014 14:01:03 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E4=BB=8E=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=A1=B5=E6=9C=AA=E5=8F=82=E5=8A=A0=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E7=8A=B6=E6=80=81=E4=B8=8B=E7=82=B9=E5=87=BB=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=AF=BE=E7=A8=8B=E8=BF=9B=E5=85=A5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/show_project.html.erb | 3 ++- app/views/users/_my_joinedcourse.html.erb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb index c14d2e14..039de6b7 100644 --- a/app/views/bids/show_project.html.erb +++ b/app/views/bids/show_project.html.erb @@ -1,8 +1,9 @@ <% if @bid.homework_type == Bid::HomeworkFile %> + <%= render :partial => 'homework' %> <% else %> - +