debian-mirror-gitlab/app/services/issues/bulk_update_service.rb

25 lines
756 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Issues
class BulkUpdateService < BaseService
def execute
2015-04-26 12:48:37 +05:30
issues_ids = params.delete(:issues_ids).split(",")
issue_params = params
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
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?
2014-09-02 18:07:02 +05:30
issues = Issue.where(id: issues_ids)
issues.each do |issue|
2015-09-11 14:41:01 +05:30
next unless can?(current_user, :update_issue, issue)
2015-04-26 12:48:37 +05:30
Issues::UpdateService.new(issue.project, current_user, issue_params).execute(issue)
2014-09-02 18:07:02 +05:30
end
{
2015-04-26 12:48:37 +05:30
count: issues.count,
success: !issues.count.zero?
2014-09-02 18:07:02 +05:30
}
end
end
end