From e5d300af0a4d6703b043c05d4178353e7e252bf2 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 5 Feb 2010 16:57:02 +0000 Subject: [PATCH] Refactor: Pull up several #find_project methods to ApplicationController git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3370 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 7 +++++++ app/controllers/members_controller.rb | 6 ------ app/controllers/projects_controller.rb | 9 --------- app/controllers/reports_controller.rb | 7 ------- app/controllers/repositories_controller.rb | 6 ------ app/controllers/wikis_controller.rb | 7 ------- 6 files changed, 7 insertions(+), 35 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 16652c8f7..74f4aef27 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -159,6 +159,13 @@ class ApplicationController < ActionController::Base def authorize_global(ctrl = params[:controller], action = params[:action], global = true) authorize(ctrl, action, global) end + + # Find project of id params[:id] + def find_project + @project = Project.find(params[:id]) + rescue ActiveRecord::RecordNotFound + render_404 + end # make sure that the user is a member of the project (or admin) if project is private # used as a before_filter for actions that do not require any particular permission on the project diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 3bfa606e1..e3f4a16e6 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -74,12 +74,6 @@ class MembersController < ApplicationController end private - def find_project - @project = Project.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - def find_member @member = Member.find(params[:id]) @project = @member.project diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index bd2e2a8dc..945e4b721 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -413,15 +413,6 @@ class ProjectsController < ApplicationController end private - # Find project of id params[:id] - # if not found, redirect to project list - # Used as a before_filter - def find_project - @project = Project.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - def find_optional_project return true unless params[:id] @project = Project.find(params[:id]) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index e8acdc661..e057c6c0a 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -86,13 +86,6 @@ class ReportsController < ApplicationController end private - # Find project of id params[:id] - def find_project - @project = Project.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - def issues_by_tracker @issues_by_tracker ||= Issue.by_tracker(@project) end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 745159ec7..714dfedde 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -190,12 +190,6 @@ class RepositoriesController < ApplicationController end private - def find_project - @project = Project.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end - def find_repository @project = Project.find(params[:id]) @repository = @project.repository diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 215d39f4b..2238651cc 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -34,11 +34,4 @@ class WikisController < ApplicationController redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki' end end - -private - def find_project - @project = Project.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end end