From 4f617af31161f3744acea83f8720e914ba3d2693 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Mon, 12 Sep 2005 13:50:42 +0000 Subject: [PATCH] Bug 306757: Templatize the 'new' section of editproducts.cgi - Patch by Gabriel Sales de Oliveira r=LpSolit a=justdave --- webtools/bugzilla/editproducts.cgi | 44 ++++++------------- .../default/admin/products/created.html.tmpl | 31 +++++++++++++ .../en/default/global/user-error.html.tmpl | 13 ++++++ 3 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 webtools/bugzilla/template/en/default/admin/products/created.html.tmpl diff --git a/webtools/bugzilla/editproducts.cgi b/webtools/bugzilla/editproducts.cgi index 46a2a2bad5bd..1197264c4ac8 100755 --- a/webtools/bugzilla/editproducts.cgi +++ b/webtools/bugzilla/editproducts.cgi @@ -377,21 +377,18 @@ if ($action eq 'add') { # if ($action eq 'new') { - $template->put_header("Adding new product"); # Cleanups and validity checks my $classification_id = 1; if (Param('useclassification')) { - CheckClassification($classification); + CheckClassificationNew($classification); $classification_id = get_classification_id($classification); + $vars->{'classification'} = $classification; } unless ($product) { - print "You must enter a name for the new product. Please press\n"; - print "Back and try again.\n"; - PutTrailer($localtrailer); - exit; + ThrowUserError("product_blank_name"); } my $existing_product = TestProduct($product); @@ -400,29 +397,23 @@ if ($action eq 'new') { # Check for exact case sensitive match: if ($existing_product eq $product) { - print "The product '$product' already exists. Please press\n"; - print "Back and try again.\n"; - PutTrailer($localtrailer); - exit; + ThrowUserError("prod_name_already_in_use", + {'product' => $product}); } # Next check for a case-insensitive match: if (lc($existing_product) eq lc($product)) { - print "The new product '$product' differs from existing product "; - print "'$existing_product' only in case. Please press\n"; - print "Back and try again.\n"; - PutTrailer($localtrailer); - exit; + ThrowUserError("prod_name_diff_in_case", + {'product' => $product, + 'existing_product' => $existing_product}); } } my $version = trim($cgi->param('version') || ''); if ($version eq '') { - print "You must enter a version for product '$product'. Please press\n"; - print "Back and try again.\n"; - PutTrailer($localtrailer); - exit; + ThrowUserError("product_must_have_version", + {'product' => $product}); } my $description = trim($cgi->param('description') || ''); @@ -542,21 +533,12 @@ if ($action eq 'new') { # Make versioncache flush unlink "$datadir/versioncache"; - print "OK, done.

\n"; - print "

You will need to - add at least one - component before you can enter bugs against this product.
"; - PutTrailer($localtrailer, - "add a new product", - "add components to this new product"); + $vars->{'product'} = $product; + $template->process("admin/products/created.html.tmpl", $vars) + || ThrowTemplateError($template->error()); exit; } - - # # action='del' -> ask if user really wants to delete # diff --git a/webtools/bugzilla/template/en/default/admin/products/created.html.tmpl b/webtools/bugzilla/template/en/default/admin/products/created.html.tmpl new file mode 100644 index 000000000000..e4229f8a23bd --- /dev/null +++ b/webtools/bugzilla/template/en/default/admin/products/created.html.tmpl @@ -0,0 +1,31 @@ +[%# 1.0@bugzilla.org %] +[%# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Bug Tracking System. + # + # Contributor(s): Gabriel S. Oliveira + #%] + +[% PROCESS global/header.html.tmpl + title = 'New Product Created' +%] +
+
+ You will need to + + add at least one component + before you can enter [% terms.bugs %] against this product + +
+ +[% PROCESS "admin/products/footer.html.tmpl" name = product %] + +[% PROCESS global/footer.html.tmpl %] diff --git a/webtools/bugzilla/template/en/default/global/user-error.html.tmpl b/webtools/bugzilla/template/en/default/global/user-error.html.tmpl index be6108e8165f..b77e58d1619c 100644 --- a/webtools/bugzilla/template/en/default/global/user-error.html.tmpl +++ b/webtools/bugzilla/template/en/default/global/user-error.html.tmpl @@ -976,6 +976,11 @@ [% ELSIF error == "prod_name_already_in_use" %] [% title = "Product name already in use" %] The product name '[% product FILTER html %]' is already in use. + + [% ELSIF error == "prod_name_diff_in_case" %] + [% title = "Product name differs only in case" %] + The product name '[% product FILTER html %]' differs from existing + product '[% existing_product FILTER html %]' only in case. [% ELSIF error == "prod_must_define_defaultmilestone" %] [% title = "Must define new default milestone" %] @@ -990,6 +995,10 @@ create the milestone '[% defaultmilestone FILTER html %]' before it can be made the default milestone for product '[% product FILTER html %]'. + [% ELSIF error == "product_blank_name" %] + [% title = "Blank Product Name Not Allowed" %] + You must enter a name for the new product. + [% ELSIF error == "product_disabled" %] [% title = BLOCK %]Product closed for [% terms.Bugs %] Entry[% END %] Sorry, entering [% terms.bugs %] into the @@ -1006,6 +1015,10 @@ You must reassign those [% terms.bugs %] to another product before you can delete this one. + [% ELSIF error == "product_must_have_version" %] + [% title = "Product needs version" %] + You must enter a version for product '[% product FILTER html %]'. + [% ELSIF error == "product_not_specified" %] [% title = "No Product Specified" %] No product specified when trying to edit components, milestones, versions