Refactor: Pull up method to ApplicationController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3938 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a6112ef40d
commit
f18b126fba
|
@ -201,7 +201,23 @@ class ApplicationController < ActionController::Base
|
||||||
def self.model_object(model)
|
def self.model_object(model)
|
||||||
write_inheritable_attribute('model_object', model)
|
write_inheritable_attribute('model_object', model)
|
||||||
end
|
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
|
# 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
|
# used as a before_filter for actions that do not require any particular permission on the project
|
||||||
def check_project_privacy
|
def check_project_privacy
|
||||||
|
|
|
@ -52,23 +52,6 @@ class IssueMovesController < ApplicationController
|
||||||
@available_statuses = Workflow.available_statuses(@project)
|
@available_statuses = Workflow.available_statuses(@project)
|
||||||
end
|
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
|
# TODO: duplicated in IssuesController
|
||||||
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
|
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
|
||||||
if unsaved_issue_ids.empty?
|
if unsaved_issue_ids.empty?
|
||||||
|
|
|
@ -359,22 +359,6 @@ private
|
||||||
render_404
|
render_404
|
||||||
end
|
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
|
def find_project
|
||||||
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
||||||
@project = Project.find(project_id)
|
@project = Project.find(project_id)
|
||||||
|
|
Loading…
Reference in New Issue