From 6dff5777cbf133d1b774488857fbb0fa274c7575 Mon Sep 17 00:00:00 2001 From: "ghendricks%novell.com" Date: Thu, 15 Feb 2007 21:46:15 +0000 Subject: [PATCH] Allow admin to edit plan type descriptions. --- .../testopia/Bugzilla/Testopia/TestPlan.pm | 20 +++++++++---------- .../testopia/admin/plantypes/add.html.tmpl | 11 +++++++++- .../testopia/admin/plantypes/edit.html.tmpl | 11 +++++++++- webtools/testopia/tr_admin.cgi | 12 +++++++---- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/webtools/testopia/Bugzilla/Testopia/TestPlan.pm b/webtools/testopia/Bugzilla/Testopia/TestPlan.pm index ce17c1375d9..ea30dc3d57c 100644 --- a/webtools/testopia/Bugzilla/Testopia/TestPlan.pm +++ b/webtools/testopia/Bugzilla/Testopia/TestPlan.pm @@ -382,19 +382,19 @@ sub last_changed { return $date; } -=head2 lookup_plan_type +=head2 plan_type_ref Returns a type name matching the given type id =cut -sub lookup_plan_type { +sub plan_type_ref { my $self = shift; my $type_id = shift; my $dbh = Bugzilla->dbh; my $type = $dbh->selectrow_hashref( - "SELECT type_id AS id, name + "SELECT type_id AS id, name, description FROM test_plan_types WHERE type_id = ?", undef, $type_id); @@ -444,14 +444,14 @@ Update the given type sub update_plan_type { my $self = shift; - my ($type_id, $name) = @_; + my ($type_id, $name, $desc) = @_; my $dbh = Bugzilla->dbh; my $type = $dbh->do( "UPDATE test_plan_types - SET name = ? + SET name = ?, description = ? WHERE type_id = ?", - undef, ($name,$type_id)); + undef, ($name, $desc, $type_id)); } @@ -463,13 +463,13 @@ Add the given type sub add_plan_type { my $self = shift; - my ($name) = @_; + my ($name, $desc) = @_; my $dbh = Bugzilla->dbh; my $type = $dbh->do( - "INSERT INTO test_plan_types (type_id, name) - VALUES(?,?)", - undef, (undef, $name)); + "INSERT INTO test_plan_types (type_id, name, description) + VALUES(?,?,?)", + undef, (undef, $name, $desc)); } =head2 get_fields diff --git a/webtools/testopia/template/en/default/testopia/admin/plantypes/add.html.tmpl b/webtools/testopia/template/en/default/testopia/admin/plantypes/add.html.tmpl index 00976f08078..e2b0d726ce1 100644 --- a/webtools/testopia/template/en/default/testopia/admin/plantypes/add.html.tmpl +++ b/webtools/testopia/template/en/default/testopia/admin/plantypes/add.html.tmpl @@ -25,7 +25,16 @@
- Type Name: + + + + + + + + + +
Type Name:
Description:
diff --git a/webtools/testopia/template/en/default/testopia/admin/plantypes/edit.html.tmpl b/webtools/testopia/template/en/default/testopia/admin/plantypes/edit.html.tmpl index 992fb15d8a9..cf4d7c5254a 100644 --- a/webtools/testopia/template/en/default/testopia/admin/plantypes/edit.html.tmpl +++ b/webtools/testopia/template/en/default/testopia/admin/plantypes/edit.html.tmpl @@ -26,7 +26,16 @@ - Type Name: + + + + + + + + + +
Type Name:
Description:
diff --git a/webtools/testopia/tr_admin.cgi b/webtools/testopia/tr_admin.cgi index d1a46a1054c..7bee7f93699 100755 --- a/webtools/testopia/tr_admin.cgi +++ b/webtools/testopia/tr_admin.cgi @@ -51,7 +51,7 @@ if ($item eq 'plan_type'){ if( $action eq 'edit'){ my $type_id = $cgi->param('type_id'); detaint_natural($type_id); - $vars->{'type'} = $plan->lookup_plan_type($type_id) + $vars->{'type'} = $plan->plan_type_ref($type_id) || ThrowUserError("invalid-test-id-non-existent", {'id' => $type_id, 'type' => 'Plan Type'}); $template->process("testopia/admin/plantypes/edit.html.tmpl", $vars) || ThrowTemplateError($template->error()); @@ -59,14 +59,16 @@ if ($item eq 'plan_type'){ elsif ($action eq 'doedit'){ my $type_id = $cgi->param('type_id'); my $type_name = $cgi->param('name') || ''; + my $type_desc = $cgi->param('description') || ''; ThrowUserError('testopia-missing-required-field', {'field' => 'name'}) if $type_name eq ''; detaint_natural($type_id); ThrowUserError("invalid-test-id-non-existent", - {'id' => $type_id, 'type' => 'Plan Type'}) unless $plan->lookup_plan_type($type_id); + {'id' => $type_id, 'type' => 'Plan Type'}) unless $plan->plan_type_ref($type_id); trick_taint($type_name); + trick_taint($type_desc); - $plan->update_plan_type($type_id, $type_name); + $plan->update_plan_type($type_id, $type_name, $type_desc); display(); } elsif ($action eq 'add'){ @@ -75,13 +77,15 @@ if ($item eq 'plan_type'){ } elsif ($action eq 'doadd'){ my $type_name = $cgi->param('name') || ''; + my $type_desc = $cgi->param('description') || ''; ThrowUserError('testopia-missing-required-field', {'field' => 'name'}) if $type_name eq ''; trick_taint($type_name); + trick_taint($type_desc); ThrowUserError('testopia-name-not-unique', {'object' => 'Plan Type', 'name' => $type_name}) if $plan->check_plan_type($type_name); - $plan->add_plan_type($type_name); + $plan->add_plan_type($type_name, $type_desc); display(); } else{