summaryrefslogtreecommitdiff
path: root/app/services/issues
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-06 15:01:13 +0100
committerDouwe Maan <douwe@gitlab.com>2015-03-06 15:01:13 +0100
commitb673d87227867f6d142ee6e615c750a600661c6b (patch)
tree9712a02ba6655cf95d06f71dcdc0156fd37f0dd0 /app/services/issues
parent8b53d9efe648f10e0572c2d8017489d0d3bb4755 (diff)
downloadgitlab-ce-b673d87227867f6d142ee6e615c750a600661c6b.tar.gz
Send notifications and leave system comments when bulk updating issues.
Diffstat (limited to 'app/services/issues')
-rw-r--r--app/services/issues/bulk_update_service.rb35
1 files changed, 10 insertions, 25 deletions
diff --git a/app/services/issues/bulk_update_service.rb b/app/services/issues/bulk_update_service.rb
index f72a346af6f..c7cd20b6b60 100644
--- a/app/services/issues/bulk_update_service.rb
+++ b/app/services/issues/bulk_update_service.rb
@@ -1,38 +1,23 @@
module Issues
class BulkUpdateService < BaseService
def execute
- update_data = params[:update]
+ issues_ids = params.delete(:issues_ids).split(",")
+ issue_params = params
- issues_ids = update_data[:issues_ids].split(",")
- milestone_id = update_data[:milestone_id]
- assignee_id = update_data[:assignee_id]
- status = update_data[:status]
-
- new_state = nil
-
- if status.present?
- if status == 'closed'
- new_state = :close
- else
- new_state = :reopen
- end
- end
-
- opts = {}
- opts[:milestone_id] = milestone_id if milestone_id.present?
- opts[:assignee_id] = assignee_id if assignee_id.present?
+ issue_params.delete(:state_event) unless issue_params[:state_event].present?
+ issue_params.delete(:milestone_id) unless issue_params[:milestone_id].present?
+ issue_params.delete(:assignee_id) unless issue_params[:assignee_id].present?
issues = Issue.where(id: issues_ids)
- issues = issues.select { |issue| can?(current_user, :modify_issue, issue) }
-
issues.each do |issue|
- issue.update_attributes(opts)
- issue.send new_state if new_state
+ next unless can?(current_user, :modify_issue, issue)
+
+ Issues::UpdateService.new(issue.project, current_user, issue_params).execute(issue)
end
{
- count: issues.count,
- success: !issues.count.zero?
+ count: issues.count,
+ success: !issues.count.zero?
}
end
end