From d8e9dba40427358ae5bfd8f8a12f766461f07876 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 2 Dec 2014 16:25:49 +0800 Subject: [PATCH] =?UTF-8?q?#1647=20=E6=AD=A3=E5=BC=8F=E7=89=88--=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=90=9C=E7=B4=A2=E7=AA=97=E5=8F=A3=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90=E8=BF=9B=E8=A1=8C=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=BF=94=E5=9B=9E500=E9=94=99=E8=AF=AF=EF=BC=88?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=8F=AF=E8=A7=81=E6=80=A7=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 4 ++-- lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index 6bb7a75d4..05b96414b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -7,7 +7,7 @@ class Course < ActiveRecord::Base STATUS_ARCHIVED = 9 attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student - belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier + #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 has_many :bid @@ -31,7 +31,7 @@ class Course < ActiveRecord::Base acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy - acts_as_attachable :view_permission => :view_files, + acts_as_attachable :view_permission => :view_course_files, :delete_permission => :manage_files validates_presence_of :password, :term,:name,:description diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 609b35415..377f2b112 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -46,6 +46,9 @@ module Redmine if self.respond_to?(:project) (respond_to?(:visible?) ? visible?(user) : true) && user.allowed_to?(self.class.attachable_options[:view_permission], self.project) + elsif self.is_a?(Course) + (respond_to?(:visible?) ? visible?(user) : true) && + user.allowed_to?(self.class.attachable_options[:view_permission], self) else return true end