Moved logic relative to project status from User to Project model (#3640).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9886 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-06-25 18:44:25 +00:00
parent 7fb2ddefde
commit 2ceb6b8230
2 changed files with 10 additions and 6 deletions
+10 -1
View File
@@ -573,11 +573,20 @@ class Project < ActiveRecord::Base
end
end
# Return true if this project is allowed to do the specified action.
# Return true if this project allows to do the specified action.
# action can be:
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
# * a permission Symbol (eg. :edit_project)
def allows_to?(action)
if archived?
# No action allowed on archived projects
return false
end
unless active? || Redmine::AccessControl.read_action?(action)
# No write action allowed on closed projects
return false
end
# No action allowed on disabled modules
if action.is_a? Hash
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
else