Allow admin to edit plan type descriptions.

This commit is contained in:
ghendricks%novell.com 2007-02-15 21:46:15 +00:00
Родитель 326aef6654
Коммит 992dbcc9a8
4 изменённых файлов: 38 добавлений и 16 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -25,7 +25,16 @@
<form method="POST" action="tr_admin.cgi">
<input type="hidden" name="item" value="plan_type" />
<input type="hidden" name="action" value="doadd" />
Type Name: <input name="name" />
<table>
<tr>
<th align="right">Type Name:</th>
<td><input name="name" /></td>
</tr>
<tr>
<th align="right" valign="top">Description:</th>
<td><textarea cols="40" name="description" ></textarea></td>
</tr>
</table>
<input type="submit" value="Commit" />
</form>

Просмотреть файл

@ -26,7 +26,16 @@
<input type="hidden" name="item" value="plan_type" />
<input type="hidden" name="action" value="doedit" />
<input type="hidden" name="type_id" value="[% type.id FILTER html %]" />
Type Name: <input name="name" value="[% type.name FILTER html %]" />
<table>
<tr>
<th align="right">Type Name:</th>
<td><input name="name" value="[% type.name FILTER html %]"/></td>
</tr>
<tr>
<th align="right" valign="top">Description:</th>
<td><textarea cols="40" name="description" >[% type.description FILTER html %]</textarea></td>
</tr>
</table>
<input type="submit" value="Commit" />
</form>

Просмотреть файл

@ -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{