]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 245375: Scheduled whining needs custom columns
authorAlbert Ting <altlist@gmail.com>
Sat, 13 Oct 2012 12:38:55 +0000 (14:38 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Sat, 13 Oct 2012 12:38:55 +0000 (14:38 +0200)
r/a=LpSolit

template/en/default/whine/mail.html.tmpl
template/en/default/whine/mail.txt.tmpl
whine.pl

index 3287dcc64284b0eec57d6e345f491efcc113f310..cfc3279c3292c28b250087547ff9f262625a6604 100644 (file)
@@ -13,6 +13,7 @@
   #     bugs: array containing hashes of fieldnames->values for each bug
   #     title: the title given in the whine scheduling mechanism
   #     name: the name of the query
+  #     columnlist: array of fieldnames to display in the mail
   # author: user object for the person who scheduled this whine
   # recipient: user object for the intended recipient of the message
   #%]
     <table width="100%">
       <tr>
         <th align="left">ID</th>
-        <th align="left">Sev</th>
-        <th align="left">Pri</th> 
-        <th align="left">HW</th>
-        <th align="left">Assignee</th>
-        <th align="left">Status</th>
-        <th align="left">Resolution</th>
-        <th align="left">Summary</th>
+        [% FOREACH col = query.columnlist %]
+          [% NEXT IF col == 'bug_id' %]
+          <th align="left">[% field_descs.$col FILTER html %]</th>
+        [% END %]
       </tr>
 
       [% FOREACH bug=query.bugs %]
         <tr>
           <td align="left"><a href="[%+ urlbase FILTER html %]show_bug.cgi?id=
               [%- bug.bug_id %]">[% bug.bug_id %]</a></td>
-          <td align="left">[% display_value("bug_severity", bug.bug_severity) FILTER html %]</td>
-          <td align="left">[% display_value("priority", bug.priority) FILTER html %]</td>
-          <td align="left">[% display_value("rep_platform", bug.rep_platform) FILTER html %]</td>
-          <td align="left">[% bug.assigned_to FILTER html %]</td>
-          <td align="left">[% display_value("bug_status", bug.bug_status) FILTER html %]</td>
-          <td align="left">[% display_value("resolution", bug.resolution) FILTER html %]</td>
-          <td align="left">[% bug.short_desc FILTER html %]</td>
+          [% FOREACH col = query.columnlist %]
+            [% NEXT IF col == 'bug_id' %]
+            <td align="left">[% display_value(col, bug.$col) FILTER html %]</td>
+          [% END %]
         </tr>
       [% END %]
     </table>
index 44ea655f2a21b7de51448c4378d99348a8caec9d..ba1e95741758cf3c71f837f47aeecffe79768734 100644 (file)
@@ -13,6 +13,7 @@
   #     bugs: array containing hashes of fieldnames->values for each bug
   #     title: the title given in the whine scheduling mechanism
   #     name: the name of the query
+  #     columnlist: array of fieldnames to display in the mail
   # author: user object for the person who scheduled this whine
   # recipient: user object for the intended recipient of the message
   #%]
   [% FOREACH bug=query.bugs %]
   [% terms.Bug +%] [%+ bug.bug_id %]:
   [%+ urlbase %]show_bug.cgi?id=[% bug.bug_id +%]
-  Priority: [%+ display_value("priority", bug.priority) -%]
-  [% field_descs.bug_severity %]: [%+ display_value("bug_severity", bug.bug_severity) -%]
-  [%+ field.descs.rep_platform %]: [%+ display_value("rep_platform", bug.rep_platform) %]
-  Assignee: [%+ bug.assigned_to %]
-    Status: [%+ display_value("bug_status", bug.bug_status) %]
-            [%- IF bug.resolution -%] Resolution: [% display_value("resolution", bug.resolution) -%]
-            [%- END %]
-   Summary: [% bug.short_desc %]
-
-   [% END %]
+  [% largest_title = 0 %]
+  [% FOREACH col = query.columnlist %]
+    [% NEXT IF col == 'bug_id' %]
+    [% IF field_descs.${col}.length > largest_title %]
+      [% largest_title = field_descs.${col}.length %]
+    [% END %]
+  [% END %]
+  [% FOREACH col = query.columnlist %]
+    [% NEXT IF col == 'bug_id' %]
+  [%+ " " FILTER repeat(largest_title - field_descs.${col}.length) %]
+  [% field_descs.$col %]: [% display_value($col, bug.$col) %]
+  [% END %]
+
+  [% END %]
+
 View as [% terms.bug %] list: [% urlbase %]buglist.cgi?cmdtype=runnamed&namedcmd=[% query.name FILTER uri %]
   [% END %]
 [% ELSE %]
index cb52029c082d0fc0e2ec665cd8ad2c3c681c630a..481b47425d81fb3ba814ee07adabcae4d8a5213c 100755 (executable)
--- a/whine.pl
+++ b/whine.pl
@@ -338,6 +338,7 @@ while (my $event = get_next_event) {
 #  - queries        array of hashes containing:
 #          - bugs:  array of hashes mapping fieldnames to values for this bug
 #          - title: text title given to this query in the whine event
+#          - columnlist: array of fieldnames to display in the mail
 #          - name:  text name of this query
 #  - schedule_id    integer id of the schedule being run
 #  - subject        Subject line for the message
@@ -408,6 +409,7 @@ sub run_queries {
               'name'          => $_->[0],
               'title'         => $_->[1],
               'onemailperbug' => $_->[2],
+              'columnlist'    => [],
               'bugs'          => [],
             }
         );
@@ -434,7 +436,16 @@ sub run_queries {
         # Bugzilla::Search to execute a saved query.  It's exceedingly weird,
         # but that's how it works.
         my $searchparams = new Bugzilla::CGI($savedquery);
-        my @orderstrings = split(/,\s*/, $searchparams->param('order'));
+
+        # Use the columnlist for the saved query, if it exists, and make
+        # sure bug_id is always in the list.
+        if (my $columnlist = $searchparams->param('columnlist')) {
+            @searchfields = split(/[\s,]+/, $columnlist);
+            unshift(@searchfields, 'bug_id') unless grep { $_ eq 'bug_id' } @searchfields;
+        }
+        push @{$thisquery->{'columnlist'}}, @searchfields;
+
+        my @orderstrings = split(/,\s*/, $searchparams->param('order') || '');
         my $search = new Bugzilla::Search(
             'fields' => \@searchfields,
             'params' => scalar $searchparams->Vars,
@@ -466,6 +477,7 @@ sub run_queries {
                     {
                         'name' => $thisquery->{'name'},
                         'title' => $thisquery->{'title'},
+                        'columnlist' => $thisquery->{'columnlist'},
                         'bugs' => [ $bug ],
                     },
                 ];