2014-09-02 18:07:02 +05:30
|
|
|
module Issues
|
|
|
|
class UpdateService < Issues::BaseService
|
|
|
|
def execute(issue)
|
|
|
|
state = params[:state_event]
|
|
|
|
|
|
|
|
case state
|
|
|
|
when 'reopen'
|
|
|
|
Issues::ReopenService.new(project, current_user, {}).execute(issue)
|
|
|
|
when 'close'
|
|
|
|
Issues::CloseService.new(project, current_user, {}).execute(issue)
|
2015-04-26 12:48:37 +05:30
|
|
|
when 'task_check'
|
|
|
|
issue.update_nth_task(params[:task_num].to_i, true)
|
|
|
|
when 'task_uncheck'
|
|
|
|
issue.update_nth_task(params[:task_num].to_i, false)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
|
|
|
|
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
|
|
|
|
|
|
|
|
old_labels = issue.labels.to_a
|
|
|
|
|
|
|
|
if params.present? && issue.update_attributes(params.except(:state_event,
|
|
|
|
:task_num))
|
2014-09-02 18:07:02 +05:30
|
|
|
issue.reset_events_cache
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
if issue.labels != old_labels
|
|
|
|
create_labels_note(
|
|
|
|
issue, issue.labels - old_labels, old_labels - issue.labels)
|
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
if issue.previous_changes.include?('milestone_id')
|
|
|
|
create_milestone_note(issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
if issue.previous_changes.include?('assignee_id')
|
|
|
|
create_assignee_note(issue)
|
2015-04-26 12:48:37 +05:30
|
|
|
notification_service.reassigned_issue(issue, current_user)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
issue.notice_added_references(issue.project, current_user)
|
|
|
|
execute_hooks(issue, 'update')
|
|
|
|
end
|
|
|
|
|
|
|
|
issue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|