]> source.dussan.org Git - redmine.git/commitdiff
Refactor: Pull up #find_optional_project to ApplicationController.
authorEric Davis <edavis@littlestreamsoftware.com>
Fri, 30 Apr 2010 17:24:11 +0000 (17:24 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Fri, 30 Apr 2010 17:24:11 +0000 (17:24 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3716 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
app/controllers/gantts_controller.rb
app/controllers/issues_controller.rb

index c0d947c8aa1b8afb2721094d6a4b1beec0789103..54339b4e9ee4628ad72c274c8448c8f2e04c7fc6 100644 (file)
@@ -168,6 +168,16 @@ class ApplicationController < ActionController::Base
     render_404
   end
 
+  # Find a project based on params[:project_id]
+  # TODO: some subclasses override this, see about merging their logic
+  def find_optional_project
+    @project = Project.find(params[:project_id]) unless params[:project_id].blank?
+    allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
+    allowed ? true : deny_access
+  rescue ActiveRecord::RecordNotFound
+    render_404
+  end
+
   # Finds and sets @project based on @object.project
   def find_project_from_association
     render_404 unless @object.present?
index 3933577c5327af234bc0e0c7b71b61867f47b52b..bc2d6350c18bc885d5c065488fd2c93a1477f885 100644 (file)
@@ -42,15 +42,4 @@ class GanttsController < ApplicationController
     end
   end
 
-  private
-
-  # TODO: Refactor, duplicates IssuesController
-  def find_optional_project
-    @project = Project.find(params[:project_id]) unless params[:project_id].blank?
-    allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
-    allowed ? true : deny_access
-  rescue ActiveRecord::RecordNotFound
-    render_404
-  end
-
 end
index 9ff4bf06d344a57f0870706f3c295c9ab45a53cf..32fd83a896fb988be12399b194d0bc082fe45ac8 100644 (file)
@@ -445,14 +445,6 @@ private
     render_404
   end
   
-  def find_optional_project
-    @project = Project.find(params[:project_id]) unless params[:project_id].blank?
-    allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
-    allowed ? true : deny_access
-  rescue ActiveRecord::RecordNotFound
-    render_404
-  end
-
   # Used by #edit and #update to set some common instance variables
   # from the params
   # TODO: Refactor, not everything in here is needed by #edit