##// END OF EJS Templates
Refactor: Pull up several #find_project methods to ApplicationController...
Eric Davis -
r3256:e5d300af0a4d
parent child
Show More
@@ -159,6 +159,13 class ApplicationController < ActionController::Base
159 def authorize_global(ctrl = params[:controller], action = params[:action], global = true)
159 def authorize_global(ctrl = params[:controller], action = params[:action], global = true)
160 authorize(ctrl, action, global)
160 authorize(ctrl, action, global)
161 end
161 end
162
163 # Find project of id params[:id]
164 def find_project
165 @project = Project.find(params[:id])
166 rescue ActiveRecord::RecordNotFound
167 render_404
168 end
162
169
163 # make sure that the user is a member of the project (or admin) if project is private
170 # make sure that the user is a member of the project (or admin) if project is private
164 # used as a before_filter for actions that do not require any particular permission on the project
171 # used as a before_filter for actions that do not require any particular permission on the project
@@ -74,12 +74,6 class MembersController < ApplicationController
74 end
74 end
75
75
76 private
76 private
77 def find_project
78 @project = Project.find(params[:id])
79 rescue ActiveRecord::RecordNotFound
80 render_404
81 end
82
83 def find_member
77 def find_member
84 @member = Member.find(params[:id])
78 @member = Member.find(params[:id])
85 @project = @member.project
79 @project = @member.project
@@ -413,15 +413,6 class ProjectsController < ApplicationController
413 end
413 end
414
414
415 private
415 private
416 # Find project of id params[:id]
417 # if not found, redirect to project list
418 # Used as a before_filter
419 def find_project
420 @project = Project.find(params[:id])
421 rescue ActiveRecord::RecordNotFound
422 render_404
423 end
424
425 def find_optional_project
416 def find_optional_project
426 return true unless params[:id]
417 return true unless params[:id]
427 @project = Project.find(params[:id])
418 @project = Project.find(params[:id])
@@ -86,13 +86,6 class ReportsController < ApplicationController
86 end
86 end
87
87
88 private
88 private
89 # Find project of id params[:id]
90 def find_project
91 @project = Project.find(params[:id])
92 rescue ActiveRecord::RecordNotFound
93 render_404
94 end
95
96 def issues_by_tracker
89 def issues_by_tracker
97 @issues_by_tracker ||= Issue.by_tracker(@project)
90 @issues_by_tracker ||= Issue.by_tracker(@project)
98 end
91 end
@@ -190,12 +190,6 class RepositoriesController < ApplicationController
190 end
190 end
191
191
192 private
192 private
193 def find_project
194 @project = Project.find(params[:id])
195 rescue ActiveRecord::RecordNotFound
196 render_404
197 end
198
199 def find_repository
193 def find_repository
200 @project = Project.find(params[:id])
194 @project = Project.find(params[:id])
201 @repository = @project.repository
195 @repository = @project.repository
@@ -34,11 +34,4 class WikisController < ApplicationController
34 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki'
34 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki'
35 end
35 end
36 end
36 end
37
38 private
39 def find_project
40 @project = Project.find(params[:id])
41 rescue ActiveRecord::RecordNotFound
42 render_404
43 end
44 end
37 end
General Comments 0
You need to be logged in to leave comments. Login now