From bab1c7f5be84477cec9a6156eb01326e594117b4 Mon Sep 17 00:00:00 2001 From: "ghendricks%novell.com" Date: Thu, 8 Feb 2007 18:21:34 +0000 Subject: [PATCH] Ability to delete multiple test cases. --- .../testopia/case/delete-list.html.tmpl | 60 +++++++++++++++ .../en/default/testopia/case/list.html.tmpl | 4 +- webtools/testopia/tr_list_cases.cgi | 74 +++++++++++++++++++ 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 webtools/testopia/template/en/default/testopia/case/delete-list.html.tmpl diff --git a/webtools/testopia/template/en/default/testopia/case/delete-list.html.tmpl b/webtools/testopia/template/en/default/testopia/case/delete-list.html.tmpl new file mode 100644 index 00000000000..2923cfe5cc4 --- /dev/null +++ b/webtools/testopia/template/en/default/testopia/case/delete-list.html.tmpl @@ -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 + #%] + +[%# 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:
+ [% FOREACH case = unable_list %] + [% case.id FILTER none %] + [% END %] +

These will be ignored

+[% END %] +You are about to delete [% delete_list.size %] test cases with all of their history
+ +
+Warning: This action cannot be undone +
+
+
+ + + +
+ +Go back to search page + +[% PROCESS global/footer.html.tmpl %] diff --git a/webtools/testopia/template/en/default/testopia/case/list.html.tmpl b/webtools/testopia/template/en/default/testopia/case/list.html.tmpl index 84b050b3a51..b59caa7f14d 100644 --- a/webtools/testopia/template/en/default/testopia/case/list.html.tmpl +++ b/webtools/testopia/template/en/default/testopia/case/list.html.tmpl @@ -89,7 +89,9 @@ No test cases [% END %] found.

- +[% IF table.list_count > 0 %] +

+[% END %] [% IF dotweak AND table.list_count %]

Update Selected Test Cases

diff --git a/webtools/testopia/tr_list_cases.cgi b/webtools/testopia/tr_list_cases.cgi index 0639cfa2c4e..94bb29b38ba 100755 --- a/webtools/testopia/tr_list_cases.cgi +++ b/webtools/testopia/tr_list_cases.cgi @@ -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 ### ###############