diff options
author | Byron Jones <glob@mozilla.com> | 2015-04-13 06:38:14 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2015-04-13 06:38:14 +0200 |
commit | 497c70791868264ddb0499970ea0323988bdcdb0 (patch) | |
tree | 500409caf735df3a138b6551e9bd0bcbbe2fc399 /extensions | |
parent | 7c5fdd252e1f7dbef712da780ce39153b1e015df (diff) | |
download | bugzilla-497c70791868264ddb0499970ea0323988bdcdb0.tar.gz bugzilla-497c70791868264ddb0499970ea0323988bdcdb0.tar.xz |
Bug 1152818: changing an assignee to nobody@mozilla.org or any .bugs address should automatically reset the status to NEW
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/BMO/Extension.pm | 37 | ||||
-rw-r--r-- | extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl | 5 |
2 files changed, 42 insertions, 0 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 52bdd53bc..5472006ed 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -735,6 +735,43 @@ sub bug_end_of_create { } } +# bugs in an ASSIGNED state must be assigned to a real person +# reset bugs to NEW if the assignee is nobody/.bugs$ +sub object_start_of_update { + my ($self, $args) = @_; + my ($new_bug, $old_bug) = @$args{qw( object old_object )}; + return unless $new_bug->isa('Bugzilla::Bug'); + + # if either the assignee or status has changed + return unless + $old_bug->assigned_to->id != $new_bug->assigned_to->id + || $old_bug->bug_status ne $new_bug->bug_status; + + # and the bug is now ASSIGNED + return unless + $new_bug->bug_status eq 'ASSIGNED'; + + # and the assignee isn't a real person + return unless + $new_bug->assigned_to->login eq 'nobody@mozilla.org' + || $new_bug->assigned_to->login =~ /\.bugs$/; + + # and the user can set the status to NEW + return unless + $old_bug->check_can_change_field('bug_status', $old_bug->bug_status, 'NEW'); + + # if the user is changing the assignee, silently change the bug's status to new + if ($old_bug->assigned_to->id != $new_bug->assigned_to->id) { + $new_bug->set_bug_status('NEW'); + } + + # otherwise the user is trying to set the bug's status to ASSIGNED without + # assigning a real person. throw an error. + else { + ThrowUserError('bug_status_unassigned'); + } +} + # detect github pull requests and reviewboard reviews, set the content-type sub attachment_process_data { my ($self, $args) = @_; diff --git a/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl index 9caf9bd29..a8be3663f 100644 --- a/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl +++ b/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl @@ -41,4 +41,9 @@ [% title = "Missing Reporter" %] You must provide an email address for a bounty attachment. +[% ELSIF error == "bug_status_unassigned" %] + [% title = "Invalid Bug Status" %] + You cannot set this [% terms.bug %]'s status to ASSIGNED because the + [%+ terms.bug %] is not assigned to a person. + [% END %] |