diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm index da9e8c3fd6f..dd74ab9aecd 100644 --- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm +++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm @@ -950,9 +950,8 @@ sub candelete { my $self = shift; return ($self->canedit - && Param('allow-test-deletion') - && scalar @{$self->get_case_run_list} == 1 - && $self->status eq 'IDLE'); + && Param('allow-test-deletion')); + } =head2 obliterate diff --git a/mozilla/webtools/testopia/template/en/default/testopia/caserun/delete.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/caserun/delete.html.tmpl new file mode 100644 index 00000000000..eec66313b1f --- /dev/null +++ b/mozilla/webtools/testopia/template/en/default/testopia/caserun/delete.html.tmpl @@ -0,0 +1,74 @@ +[%# 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 Test Runner System. + # + # The Initial Developer of the Original Code is Maciej Maczynski. + # Portions created by Maciej Maczynski are Copyright (C) 2001 + # Maciej Maczynski. All Rights Reserved. + # + # Contributor(s): Ed Fuentetaja + # Greg Hendricks + #%] + +[%# INTERFACE: + # ... + #%] + +[%############################################################################%] +[%# Template Initialization #%] +[%############################################################################%] + +[% PROCESS global/variables.none.tmpl %] + +[%############################################################################%] +[%# Page Header #%] +[%############################################################################%] + +[% PROCESS global/header.html.tmpl %] + +[% IF NOT deleted %] +[% IF caseruns %] + You are about to permanently remove [% caseruncount %] case(s) from this test run. +[% ELSE %] + You are about to permanently remove this test case from this run with all its history. +[% END %] +
+[% IF bugcount %] +This case has [% bugcount FILTER none %] [% terms.bugs %] linked to it.
+[% END %] +Warning: This action cannot be undone! +
+
+
+ + + [% IF caseruns %] + [% FOREACH c = caseruns %] + + [% END %] + [% ELSE %] + + [% END %] + +
+ +Cancel + +[% ELSE %] + +Test case(s) removed. + [% IF run_id %] + Go back to test run [% run_id FILTER none %] + [% END %] +[% END %] + +[% PROCESS global/footer.html.tmpl %] diff --git a/mozilla/webtools/testopia/template/en/default/testopia/caserun/list.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/caserun/list.html.tmpl index 362df81febc..60e88c0e23e 100644 --- a/mozilla/webtools/testopia/template/en/default/testopia/caserun/list.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/testopia/caserun/list.html.tmpl @@ -49,6 +49,9 @@
[% IF table.list_count %] [% PROCESS "testopia/caserun/case-history.html.tmpl" %] + [% IF Param('allow-test-deletion') %] +

+ [% END %] [% END %]

[% IF table.list_count == 0 %] diff --git a/mozilla/webtools/testopia/tr_list_caseruns.cgi b/mozilla/webtools/testopia/tr_list_caseruns.cgi index 12200d4177c..9613d9d42b2 100755 --- a/mozilla/webtools/testopia/tr_list_caseruns.cgi +++ b/mozilla/webtools/testopia/tr_list_caseruns.cgi @@ -33,7 +33,7 @@ use Bugzilla::Testopia::TestCaseRun; use Bugzilla::Testopia::Table; use vars qw($vars $template); -require "globals.pl"; +require 'globals.pl'; my $dbh = Bugzilla->dbh; my $cgi = Bugzilla->cgi; @@ -46,6 +46,7 @@ $cgi->send_cookie(-name => "TEST_LAST_ORDER", -expires => "Fri, 01-Jan-2038 00:00:00 GMT"); Bugzilla->login(); print $cgi->header; + my $action = $cgi->param('action') || ''; if ($action eq 'Commit'){ @@ -131,6 +132,43 @@ if ($action eq 'Commit'){ } exit; } +elsif ($action eq 'Delete Selected'){ + Bugzilla->login(LOGIN_REQUIRED); + my $reg = qr/r_([\d]+)/; + my @caseruns; + foreach my $p ($cgi->param()){ + my $caserun = Bugzilla::Testopia::TestCaseRun->new($1) if $p =~ $reg; + ThrowUserError("testopia-read-only", {'object' => 'case run'}) if ($caserun && !$caserun->candelete); + push @caseruns, $caserun if $caserun; + } + ThrowUserError('testopia-none-selected', {'object' => 'case-run'}) if (scalar @caseruns < 1); + $vars->{'caseruns'} = \@caseruns; + $vars->{'caseruncount'} = scalar @caseruns; + $vars->{'title'} = "Remove Test Cases from Run"; + $vars->{'form_action'} = 'tr_list_caseruns.cgi'; + $vars->{'run_id'} = $cgi->param('run_id'); + $template->process("testopia/caserun/delete.html.tmpl", $vars) || + ThrowTemplateError($template->error()); + exit; +} +elsif ($action eq 'do_delete'){ + Bugzilla->login(LOGIN_REQUIRED); + my @caseruns; + foreach my $id ($cgi->param('caserun_id')){ + my $caserun = Bugzilla::Testopia::TestCaseRun->new($id); + push @caseruns, $caserun; + ThrowUserError("testopia-read-only", {'object' => 'case run'}) if !$caserun->candelete; + } + foreach my $c (@caseruns){ + $c->obliterate; + } + $vars->{'deleted'} = 1; + $vars->{'run_id'} = $cgi->param('run_id'); + $template->process("testopia/caserun/delete.html.tmpl", $vars) || + ThrowTemplateError($template->error()); + exit; +} + # Take the search from the URL params and convert it to SQL $cgi->param('current_tab', 'case_run'); my $search = Bugzilla::Testopia::Search->new($cgi); diff --git a/mozilla/webtools/testopia/tr_show_caserun.cgi b/mozilla/webtools/testopia/tr_show_caserun.cgi index 4cc0bd935a9..7dbbc6182a6 100755 --- a/mozilla/webtools/testopia/tr_show_caserun.cgi +++ b/mozilla/webtools/testopia/tr_show_caserun.cgi @@ -139,6 +139,17 @@ if ($action eq 'Commit'){ display($caserun); } elsif ($action eq 'delete'){ + Bugzilla->login(LOGIN_REQUIRED); + my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id); + ThrowUserError("testopia-read-only", {'object' => 'case run'}) if !$caserun->candelete; + $vars->{'title'} = 'Remove Test Case '. $caserun->case->id .' from Run: ' . $caserun->run->summary; + $vars->{'bugcount'} = scalar @{$caserun->bugs}; + $vars->{'form_action'} = 'tr_show_caserun.cgi'; + $vars->{'caserun'} = $caserun; + $template->process("testopia/caserun/delete.html.tmpl", $vars) || + ThrowTemplateError($template->error()); +} +elsif ($action eq 'do_delete'){ Bugzilla->login(LOGIN_REQUIRED); my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id); ThrowUserError("testopia-read-only", {'object' => 'case run'}) if !$caserun->candelete;