Ability to delete multiple test cases.

This commit is contained in:
ghendricks%novell.com 2007-02-08 18:21:34 +00:00
Родитель 8afb0a1056
Коммит bab1c7f5be
3 изменённых файлов: 137 добавлений и 1 удалений

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

@ -0,0 +1,60 @@
[%# 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 Testopia.
#
# The Initial Developer of the Original Code is Greg Hendricks.
# Portions created by Greg Hendricks are Copyright (C) 2007
# Novell. All Rights Reserved.
#
# Contributor(s): Greg Hendricks <ghendricks@novell.com>
#%]
[%# INTERFACE:
# ...
#%]
[%############################################################################%]
[%# Template Initialization #%]
[%############################################################################%]
[% PROCESS global/variables.none.tmpl %]
[%############################################################################%]
[%# Page Header #%]
[%############################################################################%]
[% PROCESS global/header.html.tmpl
title = "Deleting Multiple Test Cases"
%]
[% IF unable_list.size > 0 %]
You do not have sufficient permissions to delete the following test cases:<br>
[% FOREACH case = unable_list %]
<a href="tr_show_case.cgi?case_id=[% case.id FILTER none %]">[% case.id FILTER none %]</a>
[% END %]
<p>These will be ignored</p>
[% END %]
<b>You are about to delete [% delete_list.size %] test cases with all of their history</b></br>
<br>
<span style="font-size:12pt; font-weight:bold; color:#cc0000;">Warning: This action cannot be undone</span>
<br>
<br>
<form action="tr_list_cases.cgi">
<input type="hidden" name="case_list" value="[% FOREACH c = delete_list %][% c.id FILTER none %],[% END %]" />
<input type="hidden" name="action" value="do_delete" />
<input type="submit" value="Delete These Test Cases" />
</form>
<a href="tr_query.cgi">Go back to search page</a>
[% PROCESS global/footer.html.tmpl %]

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

@ -89,7 +89,9 @@ No test cases
[% END %]
found.</b>
</p>
[% IF table.list_count > 0 %]
<p style="float: right;"><input type="submit" name="action" value="Delete Selected"></p>
[% END %]
[% IF dotweak AND table.list_count %]
<h3>Update Selected Test Cases</h3>

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

@ -242,6 +242,80 @@ if ($action eq 'Commit'){
exit;
}
elsif ($action eq 'Delete Selected'){
Bugzilla->login(LOGIN_REQUIRED);
# Match the list of checked items.
my $reg = qr/c_([\d]+)/;
my $params = join(" ", $cgi->param());
my @params = $cgi->param();
unless ($params =~ $reg){
print $cgi->multipart_end if $serverpush;
ThrowUserError('testopia-none-selected', {'object' => 'case'});
}
my @deletable;
my @undeletable;
foreach my $p ($cgi->param()){
my $case = Bugzilla::Testopia::TestCase->new($1) if $p =~ $reg;
next unless $case;
if ($case->candelete){
push @deletable, $case;
}
else {
push @undeletable, $case;
}
}
print $cgi->multipart_end if $serverpush;
$vars->{'delete_list'} = \@deletable;
$vars->{'unable_list'} = \@undeletable;
$template->process("testopia/case/delete-list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
print $cgi->multipart_final if $serverpush;
exit;
}
elsif ($action eq 'do_delete'){
Bugzilla->login(LOGIN_REQUIRED);
my @case_ids = split(",", $cgi->param('case_list'));
my $progress_interval = 250;
my $i = 0;
my $total = scalar @case_ids;
foreach my $id (@case_ids){
$i++;
if ($i % $progress_interval == 0 && $serverpush){
print $cgi->multipart_end;
print $cgi->multipart_start;
$vars->{'complete'} = $i;
$vars->{'total'} = $total;
$template->process("testopia/progress.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
detaint_natural($id);
next unless $id;
my $case = Bugzilla::Testopia::TestCase->new($id);
next unless $case->candelete;
$case->obliterate;
}
print $cgi->multipart_end if $serverpush;
my $case = Bugzilla::Testopia::TestCase->new({});
$vars->{'case'} = $case;
$vars->{'title'} = "Update Successful";
$vars->{'tr_message'} = "$i test cases deleted";
$vars->{'current_tab'} = 'case';
$template->process("testopia/search/advanced.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
print $cgi->multipart_final if $serverpush;
exit;
}
###############
### Display ###
###############