From 5a5db45af24f61c101fb2adcd514c987e1e67818 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 21 May 2014 14:44:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E6=9C=AC=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 7 ++++++- app/controllers/projects_controller.rb | 6 +++--- app/models/homework_attach.rb | 7 +++++++ lib/redmine.rb | 5 +++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d848b3c37..ed27d9388 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -209,7 +209,12 @@ private end def read_authorize - @attachment.visible? ? true : deny_access + if @attachment.container_type == "HomeworkAttach" + true + #User.current.allowed_to?(:view_homework_attaches, @attachment.project) ? true : deny_access + else + @attachment.visible? ? true : deny_access + end end def delete_authorize diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d9996e739..32fc3dd57 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -33,12 +33,12 @@ class ProjectsController < ApplicationController menu_item l(:label_course_news), :only => :index - before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise] + before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] # 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] - before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen] - before_filter :authorize_global, :only => [:new, :create] + before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches] + before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] before_filter :file, :statistics, :watcherlist diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index e395e65e5..ac285e606 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -29,6 +29,13 @@ class HomeworkAttach < ActiveRecord::Base result end + def project + work = HomeworkForCourse.find_by_bid_id(self.bid_id) + if work + work.project + end + end + def add_jours options jfm = self.journals_for_messages.build(options) jfm.save diff --git a/lib/redmine.rb b/lib/redmine.rb index d22feb9fc..904be7c25 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -178,6 +178,11 @@ Redmine::AccessControl.map do |map| map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]} end + #作业模块权限 + map.project_module :bids do |map| + map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true + end + map.project_module :boards do |map| map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true, :read => true