##// END OF EJS Templates
Refactor: Pull up #find_optional_project to ApplicationController....
Eric Davis -
r3602:306ca5e7145a
parent child
Show More
@@ -168,6 +168,16 class ApplicationController < ActionController::Base
168 render_404
168 render_404
169 end
169 end
170
170
171 # Find a project based on params[:project_id]
172 # TODO: some subclasses override this, see about merging their logic
173 def find_optional_project
174 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
175 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
176 allowed ? true : deny_access
177 rescue ActiveRecord::RecordNotFound
178 render_404
179 end
180
171 # Finds and sets @project based on @object.project
181 # Finds and sets @project based on @object.project
172 def find_project_from_association
182 def find_project_from_association
173 render_404 unless @object.present?
183 render_404 unless @object.present?
@@ -42,15 +42,4 class GanttsController < ApplicationController
42 end
42 end
43 end
43 end
44
44
45 private
46
47 # TODO: Refactor, duplicates IssuesController
48 def find_optional_project
49 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
50 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
51 allowed ? true : deny_access
52 rescue ActiveRecord::RecordNotFound
53 render_404
54 end
55
56 end
45 end
@@ -445,14 +445,6 private
445 render_404
445 render_404
446 end
446 end
447
447
448 def find_optional_project
449 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
450 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
451 allowed ? true : deny_access
452 rescue ActiveRecord::RecordNotFound
453 render_404
454 end
455
456 # Used by #edit and #update to set some common instance variables
448 # Used by #edit and #update to set some common instance variables
457 # from the params
449 # from the params
458 # TODO: Refactor, not everything in here is needed by #edit
450 # TODO: Refactor, not everything in here is needed by #edit
General Comments 0
You need to be logged in to leave comments. Login now