From 0d06b64ddb02bbfcc38c9ed88c400beb88e8b556 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 12 Sep 2005 20:50:41 +0000 Subject: Bug 306757: Templatize the 'new' section of editproducts.cgi - Patch by Gabriel Sales de Oliveira r=LpSolit a=justdave --- editproducts.cgi | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) (limited to 'editproducts.cgi') diff --git a/editproducts.cgi b/editproducts.cgi index 46a2a2bad..1197264c4 100755 --- a/editproducts.cgi +++ b/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 # -- cgit v1.2.3-24-g4f1b