From 2eaefe2301feb27594a3db755948fbddb3594838 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 27 Jun 2012 16:15:51 +0800 Subject: Bug 764430: improvements to 4.2 bugmail --- Bugzilla/BugMail.pm | 18 +- .../en/default/email/bugmail-header.txt.tmpl | 36 ++++ .../template/en/default/email/bugmail.html.tmpl | 198 +++++++++++++++++++++ .../BMO/template/en/default/email/bugmail.txt.tmpl | 74 ++++++++ template/en/default/email/bugmail.txt.tmpl | 4 - 5 files changed, 324 insertions(+), 6 deletions(-) create mode 100644 extensions/BMO/template/en/default/email/bugmail-header.txt.tmpl create mode 100644 extensions/BMO/template/en/default/email/bugmail.html.tmpl create mode 100644 extensions/BMO/template/en/default/email/bugmail.txt.tmpl diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index c7a682e4a..2a70127f1 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -47,7 +47,7 @@ use Bugzilla::Hook; use Date::Parse; use Date::Format; use Scalar::Util qw(blessed); -use List::MoreUtils qw(uniq); +use List::MoreUtils qw(uniq firstidx); use constant BIT_DIRECT => 1; use constant BIT_WATCHING => 2; @@ -490,7 +490,7 @@ sub _get_diffs { ON fielddefs.id = bugs_activity.fieldid WHERE bugs_activity.bug_id = ? $when_restriction - ORDER BY bugs_activity.bug_when", {Slice=>{}}, @args); + ORDER BY bugs_activity.bug_when, fielddefs.description", {Slice=>{}}, @args); my $referenced_bugs = []; foreach my $diff (@$diffs) { @@ -520,6 +520,20 @@ sub _get_new_bugmail_fields { my @fields = @{ Bugzilla->fields({obsolete => 0, in_new_bugmail => 1}) }; my @diffs; + # Show fields in the same order as the DEFAULT_FIELDS list, which mirrors + # 4.0's behavour and provides sane grouping of similar fields. + # Any additional fields are sorted by descrsiption + my @prepend; + foreach my $name (map { $_->{name} } Bugzilla::Field::DEFAULT_FIELDS) { + my $idx = firstidx { $_->name eq $name } @fields; + if ($idx != -1) { + push(@prepend, $fields[$idx]); + splice(@fields, $idx, 1); + } + } + @fields = sort { $a->description cmp $b->description } @fields; + @fields = (@prepend, @fields); + foreach my $field (@fields) { my $name = $field->name; my $value = $bug->$name; diff --git a/extensions/BMO/template/en/default/email/bugmail-header.txt.tmpl b/extensions/BMO/template/en/default/email/bugmail-header.txt.tmpl new file mode 100644 index 000000000..821bf2ef9 --- /dev/null +++ b/extensions/BMO/template/en/default/email/bugmail-header.txt.tmpl @@ -0,0 +1,36 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% PROCESS "global/field-descs.none.tmpl" %] +[% PROCESS "global/reason-descs.none.tmpl" %] +[% show_new = isnew + && (to_user.settings.bugmail_new_prefix.value == 'on') %] +[% isnew = bug.lastdiffed ? 0 : 1 %] + +From: [% Param('mailfrom') %] +To: [% to_user.email %] +Subject: [[% terms.Bug %] [%+ bug.id %]] [% 'New: ' IF show_new %][%+ bug.short_desc %] +Date: [% date %] +X-Bugzilla-Reason: [% reasonsheader %] +X-Bugzilla-Type: [% isnew ? 'new' : 'changed' %] +X-Bugzilla-Watch-Reason: [% reasonswatchheader %] +[% IF Param('useclassification') %] +X-Bugzilla-Classification: [% bug.classification %] +[% END %] +X-Bugzilla-ID: [% bug.id %] +X-Bugzilla-Product: [% bug.product %] +X-Bugzilla-Component: [% bug.component %] +X-Bugzilla-Keywords: [% bug.keywords %] +X-Bugzilla-Severity: [% bug.bug_severity %] +X-Bugzilla-Who: [% changer.login %] +X-Bugzilla-Status: [% bug.bug_status %] +X-Bugzilla-Priority: [% bug.priority %] +X-Bugzilla-Assigned-To: [% bug.assigned_to.login %] +X-Bugzilla-Target-Milestone: [% bug.target_milestone %] +X-Bugzilla-Changed-Fields: [% changedfields.join(" ") %] +[%+ threadingmarker %] diff --git a/extensions/BMO/template/en/default/email/bugmail.html.tmpl b/extensions/BMO/template/en/default/email/bugmail.html.tmpl new file mode 100644 index 000000000..fbbad46bf --- /dev/null +++ b/extensions/BMO/template/en/default/email/bugmail.html.tmpl @@ -0,0 +1,198 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% PROCESS "global/field-descs.none.tmpl" %] +[% PROCESS "global/reason-descs.none.tmpl" %] + +[% isnew = bug.lastdiffed ? 0 : 1 %] + + + + + + + + [% IF !to_user.in_group('editbugs') %] +
+ Do not reply to this email. You can add comments to this [% terms.bug %] at + [%# using the bug_link filter here causes a weird template error %] + + [% urlbase FILTER html %]/show_bug.cgi?id=[% bug.id FILTER none %] +
+
+ [% END %] + + [% IF isnew %] + [% PROCESS generate_new %] + [% ELSE %] + [% PROCESS generate_diffs %] + [% END %] + + [% IF new_comments.size %] +
+ [% FOREACH comment = new_comments.reverse %] +
+ [% IF comment.count %] + + [% "Comment # ${comment.count}" + FILTER bug_link(bug, { comment_num => comment.count, full_url => 1 }) FILTER none %] + on [% "$terms.Bug $bug.id" FILTER bug_link(bug, { full_url => 1 }) FILTER none %] + from [% INCLUDE global/user.html.tmpl who = comment.author %] + at [% comment.creation_ts FILTER time %] + + [% END %] +
[% comment.body_full({ wrap => 1 }) FILTER quoteUrls(bug, comment) %]
+
+ [% END %] +
+
+ [% END %] + + [% IF referenced_bugs.size %] +
+
+ Referenced [% terms.Bugs %]: + +
+
+ [% END %] + +
+
+ You are receiving this mail because: + +
+ + + +[% BLOCK generate_new %] +
+ + [% FOREACH change = diffs %] + [% PROCESS "email/bugmail-common.txt.tmpl" %] + + + + + [% END %] +
[% field_label FILTER html %] + [% IF change.field_name == "bug_id" %] + [% new_value FILTER bug_link(bug, full_url => 1) FILTER none %] + [% ELSE %] + [% new_value FILTER html %] + [% END %] +
+
+
+[% END %] + +[% BLOCK generate_diffs %] + [% SET in_table = 0 %] + [% last_changer = 0 %] + [% FOREACH change = diffs %] + [% PROCESS "email/bugmail-common.txt.tmpl" %] + [% IF changer.id != last_changer %] + [% last_changer = changer.id %] + [% IF in_table == 1 %] + + +
+ [% SET in_table = 0 %] + [% END %] + + + [% IF change.blocker %] + [% "${terms.Bug} ${bug.id}" FILTER bug_link(bug, full_url => 1) FILTER none %] + depends on + + [% terms.Bug %] [% bug.id FILTER none %], + which changed state.
+ [% ELSE %] + [% INCLUDE global/user.html.tmpl who = change.who %] changed + [%+ "${terms.Bug} ${bug.id}" FILTER bug_link(bug, full_url => 1) FILTER none %] + at [% change.bug_when FILTER time %]
:
+ [% END %] + + + [% IF in_table == 0 %] +
+
+ + [% SET in_table = 1 %] + [% END %] + + + + + + [% END %] + + + + + + + [% END %] + [% IF in_table %] +
WhatRemovedAdded
[% field_label FILTER html %] + [% IF old_value %] + [% old_value FILTER html %] + [% ELSE %] +   + [% END %] + + [% IF new_value %] + [% new_value FILTER html %] + [% ELSE %] +   + [% END %] +
+
+
+ [% END %] +[% END %] + diff --git a/extensions/BMO/template/en/default/email/bugmail.txt.tmpl b/extensions/BMO/template/en/default/email/bugmail.txt.tmpl new file mode 100644 index 000000000..8e2cc87e0 --- /dev/null +++ b/extensions/BMO/template/en/default/email/bugmail.txt.tmpl @@ -0,0 +1,74 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% PROCESS "global/field-descs.none.tmpl" %] +[% PROCESS "global/reason-descs.none.tmpl" %] + +[% isnew = bug.lastdiffed ? 0 : 1 %] + +[% IF !to_user.in_group('editbugs') %] +Do not reply to this email. You can add comments to this [% terms.bug %] at +[% END %] +[%+ PROCESS generate_diffs -%] + +[% FOREACH comment = new_comments %] + +[%- IF comment.count %] +--- Comment #[% comment.count %] from [% comment.author.identity %] --- +[% END %] +[%+ comment.body_full({ is_bugmail => 1, wrap => 1 }) %] +[% END %] +[% IF referenced_bugs.size %] + +Referenced [% terms.Bugs %]: + +[% FOREACH ref = referenced_bugs %] +[%+ urlbase %]show_bug.cgi?id=[% ref.id %] +[%+ "[" _ terms.Bug _ " " _ ref.id _ "] " _ ref.short_desc FILTER wrap_comment(76) %] +[% END %] +[% END %] + +-- [%# Protect the trailing space of the signature marker %] +You are receiving this mail because: +[% SET reason_lines = [] %] +[% FOREACH reason = reasons %] + [% reason_lines.push(reason_descs.$reason) IF reason_descs.$reason %] +[% END %] +[% FOREACH reason = reasons_watch %] + [% reason_lines.push(watch_reason_descs.$reason) + IF watch_reason_descs.$reason %] +[% END %] +[%+ reason_lines.join("\n") %] + +[% BLOCK generate_diffs %] + [% urlbase %]show_bug.cgi?id=[% bug.id %] + +[%+ last_changer = 0 %] + [% FOREACH change = diffs %] + [% IF !isnew && changer.id != last_changer %] + [% last_changer = changer.id %] + [% IF change.blocker %] + [% terms.Bug %] [%+ bug.id %] depends on [% terms.bug %] [%+ change.blocker.id %], which changed state. + +[%+ terms.Bug %] [%+ change.blocker.id %] Summary: [% change.blocker.short_desc %] +[%+ urlbase %]show_bug.cgi?id=[% change.blocker.id %] + [% ELSE %] + [%~ changer.identity %] changed: + [% END %] + + What |Removed |Added +---------------------------------------------------------------------------- +[%+ END %][%# End of IF. This indentation is intentional! ~%] + [% PROCESS "email/bugmail-common.txt.tmpl"%] + [%~ IF isnew %] + [% format_columns(2, field_label _ ":", new_value) -%] + [% ELSE %] + [% format_columns(3, field_label, old_value, new_value) -%] + [% END %] + [% END -%] +[% END %] diff --git a/template/en/default/email/bugmail.txt.tmpl b/template/en/default/email/bugmail.txt.tmpl index a2f1e7556..fed0565c7 100644 --- a/template/en/default/email/bugmail.txt.tmpl +++ b/template/en/default/email/bugmail.txt.tmpl @@ -25,10 +25,6 @@ [% isnew = bug.lastdiffed ? 0 : 1 %] -[% IF !user.in_group('editbugs') %] -Do not reply to this email. You can add comments to this [% terms.bug %] at -[% END %] - [%+ PROCESS generate_diffs -%] [% FOREACH comment = new_comments %] -- cgit v1.2.3-24-g4f1b