diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 12 | ||||
-rw-r--r-- | app/services/issues/move_service.rb | 9 | ||||
-rw-r--r-- | app/views/shared/issuable/_form.html.haml | 2 |
3 files changed, 20 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index b506d174155..6a016636e0d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -123,4 +123,16 @@ class Issue < ActiveRecord::Base note.all_references(current_user).merge_requests end.uniq.select { |mr| mr.open? && mr.closes_issue?(self) } end + + def moved? + !moved_to.nil? + end + + def can_move?(user, to_project = nil) + if to_project + return false unless user.can?(:admin_issue, to_project) + end + + !moved? && user.can?(:admin_issue, self.project) + end end diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index ce31830f2d0..47b58d973f9 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -33,6 +33,7 @@ module Issues # add_moved_to_note close_old_issue + mark_as_moved end notify_participants @@ -47,8 +48,8 @@ module Issues private def can_move? - can?(@current_user, :admin_issue, @project_old) && - can?(@current_user, :admin_issue, @project_new) + @issue_old.can_move?(@current_user) && + @issue_old.can_move?(@current_user, @project_new) end def create_new_issue @@ -96,5 +97,9 @@ module Issues def notify_participants notification_service.issue_moved(@issue_old, @issue_new, @current_user) end + + def mark_as_moved + @issue_old.update(moved_to: @issue_new) + end end end diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index d3eabe9ea64..5276afec1ca 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -67,7 +67,7 @@ - if can? current_user, :admin_label, issuable.project = link_to 'Create new label', new_namespace_project_label_path(issuable.project.namespace, issuable.project), target: :blank -- if issuable.is_a?(Issue) && can?(current_user, :admin_issue, issuable.project) +- if issuable.is_a?(Issue) && issuable.can_move?(current_user) %hr .form-group = label_tag :move_to_project_id, 'Move', class: 'control-label' |