课程、项目讨论区添加删除自己上传的附件功能

This commit is contained in:
z9hang 2014-10-09 11:23:22 +08:00
parent 9217351b1c
commit de8e3e5fac
1 changed files with 4 additions and 2 deletions

View File

@ -54,11 +54,13 @@ module Redmine
def attachments_deletable?(user=User.current)
if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course
#默认给予删除自己上传的附件的权限
(respond_to?(:visible?) ? visible?(user) : true) &&
user.allowed_to?(self.class.attachable_options[:delete_permission], self.course)
(user.allowed_to?(self.class.attachable_options[:delete_permission], self.course) || (self.has_attribute?(:author_id) && self.author == user))
else
#默认给予删除自己上传的附件的权限
(respond_to?(:visible?) ? visible?(user) : true) &&
user.allowed_to?(self.class.attachable_options[:delete_permission], self.project)
(user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) || (self.has_attribute?(:author_id) && self.author == user))
end
end