Skip to content

Commit

Permalink
Refactor: Pull up several #find_project methods to ApplicationController
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3370 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Feb 5, 2010
1 parent d7725ec commit e5d300a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 35 deletions.
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -159,6 +159,13 @@ def authorize(ctrl = params[:controller], action = params[:action], global = fal
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
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/members_controller.rb
Expand Up @@ -74,12 +74,6 @@ def autocomplete_for_member
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
Expand Down
9 changes: 0 additions & 9 deletions app/controllers/projects_controller.rb
Expand Up @@ -413,15 +413,6 @@ def activity
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])
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/reports_controller.rb
Expand Up @@ -86,13 +86,6 @@ def issue_report
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
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/repositories_controller.rb
Expand Up @@ -190,12 +190,6 @@ def graph
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
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/wikis_controller.rb
Expand Up @@ -34,11 +34,4 @@ def destroy
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

0 comments on commit e5d300a

Please sign in to comment.