Skip to content

Commit

Permalink
Refactor: Pull up method to ApplicationController.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3938 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Aug 12, 2010
1 parent a6112ef commit f18b126
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 34 deletions.
18 changes: 17 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -201,7 +201,23 @@ def find_model_object
def self.model_object(model)
write_inheritable_attribute('model_object', model)
end


# Filter for bulk issue operations
def find_issues
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
raise ActiveRecord::RecordNotFound if @issues.empty?
projects = @issues.collect(&:project).compact.uniq
if projects.size == 1
@project = projects.first
else
# TODO: let users bulk edit/move/destroy issues from different projects
render_error 'Can not bulk edit/move/destroy issues from different projects'
return false
end
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
def check_project_privacy
Expand Down
17 changes: 0 additions & 17 deletions app/controllers/issue_moves_controller.rb
Expand Up @@ -52,23 +52,6 @@ def prepare_for_issue_move
@available_statuses = Workflow.available_statuses(@project)
end

# Filter for bulk operations
# TODO: duplicated in IssuesController
def find_issues
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
raise ActiveRecord::RecordNotFound if @issues.empty?
projects = @issues.collect(&:project).compact.uniq
if projects.size == 1
@project = projects.first
else
# TODO: let users bulk edit/move/destroy issues from different projects
render_error 'Can not bulk edit/move/destroy issues from different projects'
return false
end
rescue ActiveRecord::RecordNotFound
render_404
end

# TODO: duplicated in IssuesController
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
if unsaved_issue_ids.empty?
Expand Down
16 changes: 0 additions & 16 deletions app/controllers/issues_controller.rb
Expand Up @@ -359,22 +359,6 @@ def find_issue
render_404
end

# Filter for bulk operations
def find_issues
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
raise ActiveRecord::RecordNotFound if @issues.empty?
projects = @issues.collect(&:project).compact.uniq
if projects.size == 1
@project = projects.first
else
# TODO: let users bulk edit/move/destroy issues from different projects
render_error 'Can not bulk edit/move/destroy issues from different projects'
return false
end
rescue ActiveRecord::RecordNotFound
render_404
end

def find_project
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
@project = Project.find(project_id)
Expand Down

0 comments on commit f18b126

Please sign in to comment.