]> source.dussan.org Git - redmine.git/commitdiff
Moved logic relative to project status from User to Project model (#3640).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 Jun 2012 18:44:25 +0000 (18:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 Jun 2012 18:44:25 +0000 (18:44 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9886 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
app/models/user.rb

index 966806ca950e55d4fe16e0ba2689c54519b5fb12..425d61d5d2064972988e92e6669fb1612409b520 100644 (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
index 1b7a8ea4ff9dd7ee753f26128de76cf6ae5c0d20..37d8b5f7c8006e9ea66e059e3c919822ae8f40ff 100644 (file)
@@ -455,12 +455,7 @@ class User < Principal
   #   or falls back to Non Member / Anonymous permissions depending if the user is logged
   def allowed_to?(action, context, options={}, &block)
     if context && context.is_a?(Project)
-      # No action allowed on archived projects
-      return false if context.archived?
-      # No action allowed on disabled modules
       return false unless context.allows_to?(action)
-      # No write action allowed on closed projects
-      return false unless context.active? || Redmine::AccessControl.read_action?(action)
       # Admin users are authorized for anything else
       return true if admin?