Commit 4aa03da5 authored by terry%mozilla.org's avatar terry%mozilla.org

Added the concept of a "default milstone" for products, and make sure

that all products have at least that milestone defined.
parent 71eef169
...@@ -660,7 +660,8 @@ $table{products} = ...@@ -660,7 +660,8 @@ $table{products} =
disallownew tinyint not null, disallownew tinyint not null,
votesperuser smallint not null, votesperuser smallint not null,
maxvotesperbug smallint not null default 10000, maxvotesperbug smallint not null default 10000,
votestoconfirm smallint not null votestoconfirm smallint not null,
defaultmilestone varchar(20) not null default "---"
'; ';
...@@ -1073,8 +1074,15 @@ sub ChangeFieldType ($$$) ...@@ -1073,8 +1074,15 @@ sub ChangeFieldType ($$$)
my $ref = GetFieldDef($table, $field); my $ref = GetFieldDef($table, $field);
#print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n"; #print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n";
if ($$ref[1] ne $newtype) { my $oldtype = $ref->[1];
if ($ref->[4]) {
$oldtype .= qq{ default "$ref->[4]"};
}
if ($oldtype ne $newtype) {
print "Updating field type $field in table $table ...\n"; print "Updating field type $field in table $table ...\n";
print "old: $oldtype\n";
print "new: $newtype\n";
$newtype .= " NOT NULL" if $$ref[3]; $newtype .= " NOT NULL" if $$ref[3];
$dbh->do("ALTER TABLE $table $dbh->do("ALTER TABLE $table
CHANGE $field CHANGE $field
...@@ -1543,8 +1551,31 @@ if (!($sth->fetchrow_arrayref()->[0])) { ...@@ -1543,8 +1551,31 @@ if (!($sth->fetchrow_arrayref()->[0])) {
# the size of the target_milestone field in the bugs table. # the size of the target_milestone field in the bugs table.
ChangeFieldType('bugs', 'target_milestone', ChangeFieldType('bugs', 'target_milestone',
'varchar(20) not null default "---"'); 'varchar(20) default "---"');
ChangeFieldType('milestones', 'value', 'varchar(20) not null'); ChangeFieldType('milestones', 'value', 'varchar(20)');
# 2000-03-23 Added a defaultmilestone field to the products table, so that
# we know which milestone to initially assign bugs to.
if (!GetFieldDef('products', 'defaultmilestone')) {
AddField('products', 'defaultmilestone',
'varchar(20) not null default "---"');
$sth = $dbh->prepare("SELECT product, defaultmilestone FROM products");
$sth->execute();
while (my ($product, $defaultmilestone) = $sth->fetchrow_array()) {
$product = $dbh->quote($product);
$defaultmilestone = $dbh->quote($defaultmilestone);
my $s2 = $dbh->prepare("SELECT value FROM milestones " .
"WHERE value = $defaultmilestone " .
"AND product = $product");
$s2->execute();
if (!$s2->fetchrow_array()) {
$dbh->do("INSERT INTO milestones(value, product) " .
"VALUES ($defaultmilestone, $product)");
}
}
}
# #
...@@ -1563,3 +1594,4 @@ if ($regenerateshadow) { ...@@ -1563,3 +1594,4 @@ if ($regenerateshadow) {
print "Now regenerating the shadow database for all bugs.\n"; print "Now regenerating the shadow database for all bugs.\n";
system("./processmail regenerate"); system("./processmail regenerate");
} }
unlink "data/versioncache";
...@@ -336,6 +336,10 @@ if ($action eq 'del') { ...@@ -336,6 +336,10 @@ if ($action eq 'del') {
AND target_milestone=" . SqlQuote($milestone)); AND target_milestone=" . SqlQuote($milestone));
my $bugs = FetchOneColumn(); my $bugs = FetchOneColumn();
SendSQL("SELECT defaultmilestone FROM products " .
"WHERE product=" . SqlQuote($product));
my $defaultmilestone = FetchOneColumn();
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0>\n"; print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0>\n";
print "<TR BGCOLOR=\"#6666FF\">\n"; print "<TR BGCOLOR=\"#6666FF\">\n";
print " <TH VALIGN=\"top\" ALIGN=\"left\">Part</TH>\n"; print " <TH VALIGN=\"top\" ALIGN=\"left\">Part</TH>\n";
...@@ -369,6 +373,13 @@ one."; ...@@ -369,6 +373,13 @@ one.";
"</TD></TR></TABLE>\n"; "</TD></TR></TABLE>\n";
} }
if ($defaultmilestone eq $milestone) {
print "Sorry; this is the default milestone for this product, and " .
"so it can not be deleted.";
PutTrailer($localtrailer);
exit;
}
print "<P>Do you really want to delete this milestone?<P>\n"; print "<P>Do you really want to delete this milestone?<P>\n";
print "<FORM METHOD=POST ACTION=editmilestones.cgi>\n"; print "<FORM METHOD=POST ACTION=editmilestones.cgi>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Yes, delete\">\n"; print "<INPUT TYPE=SUBMIT VALUE=\"Yes, delete\">\n";
...@@ -499,7 +510,8 @@ if ($action eq 'update') { ...@@ -499,7 +510,8 @@ if ($action eq 'update') {
CheckMilestone($product,$milestoneold); CheckMilestone($product,$milestoneold);
SendSQL("LOCK TABLES bugs WRITE, SendSQL("LOCK TABLES bugs WRITE,
milestones WRITE"); milestones WRITE,
products WRITE");
if ($milestone ne $milestoneold) { if ($milestone ne $milestoneold) {
unless ($milestone) { unless ($milestone) {
...@@ -522,6 +534,10 @@ if ($action eq 'update') { ...@@ -522,6 +534,10 @@ if ($action eq 'update') {
SET value=" . SqlQuote($milestone) . " SET value=" . SqlQuote($milestone) . "
WHERE product=" . SqlQuote($product) . " WHERE product=" . SqlQuote($product) . "
AND value=" . SqlQuote($milestoneold)); AND value=" . SqlQuote($milestoneold));
SendSQL("UPDATE products " .
"SET defaultmilestone = " . SqlQuote($milestone) .
"WHERE product = " . SqlQuote($product) .
" AND defaultmilestone = " . SqlQuote($milestoneold));
unlink "data/versioncache"; unlink "data/versioncache";
print "Updated milestone.<BR>\n"; print "Updated milestone.<BR>\n";
} }
......
...@@ -79,10 +79,11 @@ sub CheckProduct ($) ...@@ -79,10 +79,11 @@ sub CheckProduct ($)
# Displays the form to edit a products parameters # Displays the form to edit a products parameters
# #
sub EmitFormElements ($$$$$$$$) sub EmitFormElements ($$$$$$$$$)
{ {
my ($product, $description, $milestoneurl, $userregexp, $disallownew, my ($product, $description, $milestoneurl, $userregexp, $disallownew,
$votesperuser, $maxvotesperbug, $votestoconfirm) = @_; $votesperuser, $maxvotesperbug, $votestoconfirm, $defaultmilestone)
= @_;
$product = value_quote($product); $product = value_quote($product);
$description = value_quote($description); $description = value_quote($description);
...@@ -94,11 +95,19 @@ sub EmitFormElements ($$$$$$$$) ...@@ -94,11 +95,19 @@ sub EmitFormElements ($$$$$$$$)
print " <TH ALIGN=\"right\">Description:</TH>\n"; print " <TH ALIGN=\"right\">Description:</TH>\n";
print " <TD><TEXTAREA ROWS=4 COLS=64 WRAP=VIRTUAL NAME=\"description\">$description</TEXTAREA></TD>\n"; print " <TD><TEXTAREA ROWS=4 COLS=64 WRAP=VIRTUAL NAME=\"description\">$description</TEXTAREA></TD>\n";
$defaultmilestone = value_quote($defaultmilestone);
if (Param('usetargetmilestone')) { if (Param('usetargetmilestone')) {
$milestoneurl = value_quote($milestoneurl); $milestoneurl = value_quote($milestoneurl);
print "</TR><TR>\n"; print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Milestone URL:</TH>\n"; print " <TH ALIGN=\"right\">Milestone URL:</TH>\n";
print " <TD><INPUT TYPE=TEXT SIZE=64 MAXLENGTH=255 NAME=\"milestoneurl\" VALUE=\"$milestoneurl\"></TD>\n"; print " <TD><INPUT TYPE=TEXT SIZE=64 MAXLENGTH=255 NAME=\"milestoneurl\" VALUE=\"$milestoneurl\"></TD>\n";
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Default milestone:</TH>\n";
print " <TD><INPUT TYPE=TEXT SIZE=20 MAXLENGTH=20 NAME=\"defaultmilestone\" VALUE=\"$defaultmilestone\"></TD>\n";
} else {
print qq{<INPUT TYPE=HIDDEN NAME="defaultmilestone" VALUE="$defaultmilestone">\n};
} }
# Added -JMR, 2/16/00 # Added -JMR, 2/16/00
...@@ -229,7 +238,7 @@ unless ($action) { ...@@ -229,7 +238,7 @@ unless ($action) {
print "</TR>"; print "</TR>";
} }
print "<TR>\n"; print "<TR>\n";
print " <TD VALIGN=\"top\" COLSPAN=5>Add a new product</TD>\n"; print " <TD VALIGN=\"top\" COLSPAN=7>Add a new product</TD>\n";
print " <TD VALIGN=\"top\" ALIGN=\"middle\"><FONT SIZE =-1><A HREF=\"editproducts.cgi?action=add\">Add</A></FONT></TD>\n"; print " <TD VALIGN=\"top\" ALIGN=\"middle\"><FONT SIZE =-1><A HREF=\"editproducts.cgi?action=add\">Add</A></FONT></TD>\n";
print "</TR></TABLE>\n"; print "</TR></TABLE>\n";
...@@ -254,7 +263,7 @@ if ($action eq 'add') { ...@@ -254,7 +263,7 @@ if ($action eq 'add') {
print "<FORM METHOD=POST ACTION=editproducts.cgi>\n"; print "<FORM METHOD=POST ACTION=editproducts.cgi>\n";
print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0><TR>\n"; print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0><TR>\n";
EmitFormElements('', '', '', '', 0, 0, 10000, 0); EmitFormElements('', '', '', '', 0, 0, 10000, 0, "---");
print "</TR><TR>\n"; print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Version:</TH>\n"; print " <TH ALIGN=\"right\">Version:</TH>\n";
...@@ -315,23 +324,28 @@ if ($action eq 'new') { ...@@ -315,23 +324,28 @@ if ($action eq 'new') {
$maxvotesperbug = 10000 if !defined $maxvotesperbug; $maxvotesperbug = 10000 if !defined $maxvotesperbug;
my $votestoconfirm = $::FORM{votestoconfirm}; my $votestoconfirm = $::FORM{votestoconfirm};
$votestoconfirm ||= 0; $votestoconfirm ||= 0;
my $defaultmilestone = $::FORM{defaultmilestone} || "---";
# Add the new product. # Add the new product.
SendSQL("INSERT INTO products ( " . SendSQL("INSERT INTO products ( " .
"product, description, milestoneurl, disallownew, votesperuser, " . "product, description, milestoneurl, disallownew, votesperuser, " .
"maxvotesperbug, votestoconfirm" . "maxvotesperbug, votestoconfirm, defaultmilestone" .
" ) VALUES ( " . " ) VALUES ( " .
SqlQuote($product) . "," . SqlQuote($product) . "," .
SqlQuote($description) . "," . SqlQuote($description) . "," .
SqlQuote($milestoneurl) . "," . SqlQuote($milestoneurl) . "," .
$disallownew . "," . $disallownew . "," .
"$votesperuser, $maxvotesperbug, $votestoconfirm)"); "$votesperuser, $maxvotesperbug, $votestoconfirm, " .
SqlQuote($defaultmilestone) . ")");
SendSQL("INSERT INTO versions ( " . SendSQL("INSERT INTO versions ( " .
"value, program" . "value, program" .
" ) VALUES ( " . " ) VALUES ( " .
SqlQuote($version) . "," . SqlQuote($version) . "," .
SqlQuote($product) . ")" ); SqlQuote($product) . ")" );
SendSQL("INSERT INTO milestones (product, value) VALUES (" .
SqlQuote($product) . ", " . SqlQuote($defaultmilestone) . ")");
# If we're using bug groups, then we need to create a group for this # If we're using bug groups, then we need to create a group for this
# product as well. -JMR, 2/16/00 # product as well. -JMR, 2/16/00
if(Param("usebuggroups")) { if(Param("usebuggroups")) {
...@@ -668,11 +682,11 @@ if ($action eq 'edit') { ...@@ -668,11 +682,11 @@ if ($action eq 'edit') {
# get data of product # get data of product
SendSQL("SELECT description,milestoneurl,disallownew, SendSQL("SELECT description,milestoneurl,disallownew,
votesperuser,maxvotesperbug,votestoconfirm votesperuser,maxvotesperbug,votestoconfirm,defaultmilestone
FROM products FROM products
WHERE product=" . SqlQuote($product)); WHERE product=" . SqlQuote($product));
my ($description, $milestoneurl, $disallownew, my ($description, $milestoneurl, $disallownew,
$votesperuser, $maxvotesperbug, $votestoconfirm) = $votesperuser, $maxvotesperbug, $votestoconfirm, $defaultmilestone) =
FetchSQLData(); FetchSQLData();
my $userregexp = ''; my $userregexp = '';
...@@ -688,7 +702,7 @@ if ($action eq 'edit') { ...@@ -688,7 +702,7 @@ if ($action eq 'edit') {
EmitFormElements($product, $description, $milestoneurl, $userregexp, EmitFormElements($product, $description, $milestoneurl, $userregexp,
$disallownew, $votesperuser, $maxvotesperbug, $disallownew, $votesperuser, $maxvotesperbug,
$votestoconfirm); $votestoconfirm, $defaultmilestone);
print "</TR><TR VALIGN=top>\n"; print "</TR><TR VALIGN=top>\n";
print " <TH ALIGN=\"right\"><A HREF=\"editcomponents.cgi?product=", url_quote($product), "\">Edit components:</A></TH>\n"; print " <TH ALIGN=\"right\"><A HREF=\"editcomponents.cgi?product=", url_quote($product), "\">Edit components:</A></TH>\n";
...@@ -780,6 +794,8 @@ if ($action eq 'edit') { ...@@ -780,6 +794,8 @@ if ($action eq 'edit') {
print "<INPUT TYPE=HIDDEN NAME=\"votesperuserold\" VALUE=\"$votesperuser\">\n"; print "<INPUT TYPE=HIDDEN NAME=\"votesperuserold\" VALUE=\"$votesperuser\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"maxvotesperbugold\" VALUE=\"$maxvotesperbug\">\n"; print "<INPUT TYPE=HIDDEN NAME=\"maxvotesperbugold\" VALUE=\"$maxvotesperbug\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"votestoconfirmold\" VALUE=\"$votestoconfirm\">\n"; print "<INPUT TYPE=HIDDEN NAME=\"votestoconfirmold\" VALUE=\"$votestoconfirm\">\n";
$defaultmilestone = value_quote($defaultmilestone);
print "<INPUT TYPE=HIDDEN NAME=\"defaultmilestoneold\" VALUE=\"$defaultmilestone\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"update\">\n"; print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"update\">\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Update\">\n"; print "<INPUT TYPE=SUBMIT VALUE=\"Update\">\n";
...@@ -800,21 +816,23 @@ if ($action eq 'edit') { ...@@ -800,21 +816,23 @@ if ($action eq 'edit') {
if ($action eq 'update') { if ($action eq 'update') {
PutHeader("Update product"); PutHeader("Update product");
my $productold = trim($::FORM{productold} || ''); my $productold = trim($::FORM{productold} || '');
my $description = trim($::FORM{description} || ''); my $description = trim($::FORM{description} || '');
my $descriptionold = trim($::FORM{descriptionold} || ''); my $descriptionold = trim($::FORM{descriptionold} || '');
my $disallownew = trim($::FORM{disallownew} || ''); my $disallownew = trim($::FORM{disallownew} || '');
my $disallownewold = trim($::FORM{disallownewold} || ''); my $disallownewold = trim($::FORM{disallownewold} || '');
my $milestoneurl = trim($::FORM{milestoneurl} || ''); my $milestoneurl = trim($::FORM{milestoneurl} || '');
my $milestoneurlold = trim($::FORM{milestoneurlold} || ''); my $milestoneurlold = trim($::FORM{milestoneurlold} || '');
my $votesperuser = trim($::FORM{votesperuser} || 0); my $votesperuser = trim($::FORM{votesperuser} || 0);
my $votesperuserold = trim($::FORM{votesperuserold} || ''); my $votesperuserold = trim($::FORM{votesperuserold} || 0);
my $userregexp = trim($::FORM{userregexp} || ''); my $userregexp = trim($::FORM{userregexp} || '');
my $userregexpold = trim($::FORM{userregexpold} || ''); my $userregexpold = trim($::FORM{userregexpold} || '');
my $maxvotesperbug = trim($::FORM{maxvotesperbug} || 0); my $maxvotesperbug = trim($::FORM{maxvotesperbug} || 0);
my $maxvotesperbugold = trim($::FORM{maxvotesperbugold} || ''); my $maxvotesperbugold = trim($::FORM{maxvotesperbugold} || 0);
my $votestoconfirm = trim($::FORM{votestoconfirm} || 0); my $votestoconfirm = trim($::FORM{votestoconfirm} || 0);
my $votestoconfirmold = trim($::FORM{votestoconfirmold} || ''); my $votestoconfirmold = trim($::FORM{votestoconfirmold} || 0);
my $defaultmilestone = trim($::FORM{defaultmilestone} || '---');
my $defaultmilestoneold = trim($::FORM{defaultmilestoneold} || '---');
my $checkvotes = 0; my $checkvotes = 0;
...@@ -955,6 +973,22 @@ if ($action eq 'update') { ...@@ -955,6 +973,22 @@ if ($action eq 'update') {
} }
if ($defaultmilestone ne $defaultmilestoneold) {
SendSQL("SELECT value FROM milestones " .
"WHERE value = " . SqlQuote($defaultmilestone) .
" AND product = " . SqlQuote($productold));
if (!FetchOneColumn()) {
print "Sorry, the milestone $defaultmilestone must be defined first.";
SendSQL("UNLOCK TABLES");
PutTrailer($localtrailer);
exit;
}
SendSQL("UPDATE products " .
"SET defaultmilestone = " . SqlQuote($defaultmilestone) .
"WHERE product=" . SqlQuote($productold));
print "Updated default milestone.<BR>\n";
}
my $qp = SqlQuote($product); my $qp = SqlQuote($product);
my $qpold = SqlQuote($productold); my $qpold = SqlQuote($productold);
......
...@@ -105,7 +105,8 @@ $::FORM{'reporter'} = DBNameToIdAndCheck($::FORM{'reporter'}); ...@@ -105,7 +105,8 @@ $::FORM{'reporter'} = DBNameToIdAndCheck($::FORM{'reporter'});
my @bug_fields = ("reporter", "product", "version", "rep_platform", my @bug_fields = ("reporter", "product", "version", "rep_platform",
"bug_severity", "priority", "op_sys", "assigned_to", "bug_severity", "priority", "op_sys", "assigned_to",
"bug_status", "bug_file_loc", "short_desc", "component"); "bug_status", "bug_file_loc", "short_desc", "component",
"target_milestone");
if (Param("useqacontact")) { if (Param("useqacontact")) {
SendSQL("select initialqacontact from components where program=" . SendSQL("select initialqacontact from components where program=" .
...@@ -139,11 +140,19 @@ if (!exists $::FORM{'bug_status'}) { ...@@ -139,11 +140,19 @@ if (!exists $::FORM{'bug_status'}) {
} }
} }
if (!exists $::FORM{'target_milestone'}) {
SendSQL("SELECT defaultmilestone FROM products " .
"WHERE product = " . SqlQuote($::FORM{'product'}));
$::FORM{'target_milestone'} = FetchOneColumn();
}
if ( Param("strictvaluechecks") ) { if ( Param("strictvaluechecks") ) {
GetVersionTable(); GetVersionTable();
CheckFormField(\%::FORM, 'reporter'); CheckFormField(\%::FORM, 'reporter');
CheckFormField(\%::FORM, 'product', \@::legal_product); CheckFormField(\%::FORM, 'product', \@::legal_product);
CheckFormField(\%::FORM, 'version', \@{$::versions{$::FORM{'product'}}}); CheckFormField(\%::FORM, 'version', \@{$::versions{$::FORM{'product'}}});
CheckFormField(\%::FORM, 'target_milestone',
\@{$::target_milestone{$::FORM{'product'}}});
CheckFormField(\%::FORM, 'rep_platform', \@::legal_platform); CheckFormField(\%::FORM, 'rep_platform', \@::legal_platform);
CheckFormField(\%::FORM, 'bug_severity', \@::legal_severity); CheckFormField(\%::FORM, 'bug_severity', \@::legal_severity);
CheckFormField(\%::FORM, 'priority', \@::legal_priority); CheckFormField(\%::FORM, 'priority', \@::legal_priority);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment