]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1510109 - Implement per-product new bug comment templates
authorKohei Yoshino <kohei.yoshino@gmail.com>
Wed, 12 Dec 2018 14:34:16 +0000 (15:34 +0100)
committerDylan William Hardison <dylan@hardison.net>
Wed, 12 Dec 2018 14:34:16 +0000 (09:34 -0500)
Bugzilla/Product.pm
editproducts.cgi
enter_bug.cgi
template/en/default/admin/products/edit-common.html.tmpl

index a0ba5da273c3a4c0ae895b48df211f7ec7089701..341655c933e444ed155cfec64e87404552505103 100644 (file)
@@ -55,6 +55,7 @@ use constant UPDATE_COLUMNS => qw(
   defaultmilestone
   isactive
   allows_unconfirmed
+  bug_description_template
 );
 
 use constant VALIDATORS => {
@@ -521,6 +522,7 @@ sub set_description        { $_[0]->set('description',        $_[1]); }
 sub set_default_milestone  { $_[0]->set('defaultmilestone',   $_[1]); }
 sub set_is_active          { $_[0]->set('isactive',           $_[1]); }
 sub set_allows_unconfirmed { $_[0]->set('allows_unconfirmed', $_[1]); }
+sub set_bug_description_template { $_[0]->set('bug_description_template', $_[1]); }
 
 sub set_group_controls {
   my ($self, $group, $settings) = @_;
@@ -901,6 +903,17 @@ sub is_active          { return $_[0]->{'isactive'}; }
 sub default_milestone  { return $_[0]->{'defaultmilestone'}; }
 sub classification_id  { return $_[0]->{'classification_id'}; }
 
+# Lazy-load the bug_description_template column
+sub bug_description_template {
+  my $self = shift;
+  if (!exists $self->{'bug_description_template'}) {
+    $self->{'bug_description_template'} = Bugzilla->dbh->selectrow_array(
+      'SELECT bug_description_template FROM products WHERE id = ?',
+      undef, $self->id);
+  }
+  return $self->{'bug_description_template'};
+}
+
 ###############################
 ####      Subroutines    ######
 ###############################
@@ -953,6 +966,7 @@ Bugzilla::Product - Bugzilla product class.
     my $defaultmilestone = $product->default_milestone;
     my $classificationid = $product->classification_id;
     my $allows_unconfirmed = $product->allows_unconfirmed;
+    my $bug_description_template = $product->bug_description_template;
 
 =head1 DESCRIPTION
 
index 7deab1d2d1471923cb9f972193375693daa8979b..80cf83da17d59233ca740c5fd2830061f30ba6d6 100755 (executable)
@@ -165,6 +165,7 @@ if ($action eq 'new') {
     isactive           => scalar $cgi->param('is_active'),
     create_series      => scalar $cgi->param('createseries'),
     allows_unconfirmed => scalar $cgi->param('allows_unconfirmed'),
+    bug_description_template => scalar $cgi->param('bug_description_template'),
   );
   my $product = Bugzilla::Product->create(\%create_params);
 
@@ -283,6 +284,7 @@ if ($action eq 'update') {
     is_active          => scalar $cgi->param('is_active'),
     allows_unconfirmed => scalar $cgi->param('allows_unconfirmed'),
     default_milestone  => scalar $cgi->param('defaultmilestone'),
+    bug_description_template => scalar $cgi->param('bug_description_template'),
   });
 
   my $changes = $product->update();
index 7276fd96296eefc2284958f17dd98bec5064d10d..a2d14e6b758855045e6fb9b0016032346200287f 100755 (executable)
@@ -335,7 +335,7 @@ else {
 
   $vars->{'cc'} = join(', ', $cgi->param('cc'));
 
-  $vars->{'comment'}            = formvalue('comment');
+  $vars->{'comment'}            = formvalue('comment', $product->bug_description_template);
   $vars->{'comment_is_private'} = formvalue('comment_is_private');
 
   # BMO Add support for mentors
index 2bb0c8920e4140d36936fc03bbe29424ae5310e2..05ec2864b3eeaede4ecb05126be22475382b2747 100644 (file)
         [% product.description FILTER html %]</textarea>
   </td>
 </tr>
+<tr>
+  <th align="right">New [% terms.bug %] comment template:</th>
+  <td><textarea rows="8" cols="64" wrap="virtual" name="bug_description_template">
+        [% product.bug_description_template FILTER html %]</textarea>
+  </td>
+</tr>
 
 [% IF Param('usetargetmilestone') -%]
   <tr>