Bug 743652 (part 2: tr_case_reports.cgi): Move all tr_*.cgi code into Extension.pm
r=LpSolit git-svn-id: svn://10.0.0.236/trunk@265873 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1 +1 @@
|
||||
686
|
||||
687
|
||||
@@ -1 +1 @@
|
||||
f1c2c3a9c4b0518f3b14eacea0abdfb84dddbdad
|
||||
99bbb3f4da35fd72b08573e956f3eddff4cab32e
|
||||
@@ -347,6 +347,10 @@ sub page_before_template {
|
||||
require Bugzilla::Extension::Testopia::Admin;
|
||||
Bugzilla::Extension::Testopia::Admin::report($vars);
|
||||
}
|
||||
elsif ($page eq 'tr_case_reports.html') {
|
||||
require Bugzilla::Extension::Testopia::Reports::Case;
|
||||
Bugzilla::Extension::Testopia::Reports::Case::report($vars);
|
||||
}
|
||||
}
|
||||
|
||||
sub post_bug_after_creation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
// by Edd Dumbill (C) 1999-2002
|
||||
// <edd@usefulinc.com>
|
||||
// $Id: .xmlrpc.inc.php,v 1.49 2015-03-15 14:30:16 bzrmirror%bugzilla.org Exp $
|
||||
// $Id: .xmlrpc.inc.php,v 1.50 2015-03-15 15:00:19 bzrmirror%bugzilla.org Exp $
|
||||
|
||||
// Copyright (c) 1999,2000,2002 Edd Dumbill.
|
||||
// All rights reserved.
|
||||
|
||||
@@ -341,6 +341,7 @@ Testopia.Search.CasesForm = function(params){
|
||||
}
|
||||
catch(err){}
|
||||
if (params.report){
|
||||
values.id = 'tr_case_reports.html';
|
||||
Ext.getCmp('object_panel').add(new Ext.Panel({
|
||||
id: 'case_search' + searchnum,
|
||||
closable: true,
|
||||
@@ -348,7 +349,7 @@ Testopia.Search.CasesForm = function(params){
|
||||
autoScroll: true,
|
||||
listeners: { 'render': function(){
|
||||
this.load({
|
||||
url: 'tr_case_reports.cgi',
|
||||
url: 'page.cgi',
|
||||
params: values
|
||||
});
|
||||
}},
|
||||
|
||||
@@ -310,7 +310,7 @@ sub init {
|
||||
|
||||
$self->{'data'} = \%data;
|
||||
$self->{'image_data'} = \@image_data;
|
||||
$self->{'report_loc'} = "tr_" . $type . "_reports.cgi";
|
||||
$self->{'report_loc'} = "page.cgi?id=tr_" . $type . "_reports.html";
|
||||
if ($cgi->param('debug')) {
|
||||
print $cgi->header;
|
||||
require Data::Dumper;
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
# defined by the Mozilla Public License, v. 2.0.
|
||||
|
||||
package Bugzilla::Extension::Testopia::Reports::Case;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Bugzilla::Constants;
|
||||
use Bugzilla::Error;
|
||||
use Bugzilla::Util;
|
||||
|
||||
use Bugzilla::Extension::Testopia::Report;
|
||||
use Bugzilla::Extension::Testopia::TestCase;
|
||||
use Bugzilla::Extension::Testopia::TestCaseRun;
|
||||
|
||||
sub report {
|
||||
my ($vars) = @_;
|
||||
my $input = Bugzilla->input_params;
|
||||
my $template = Bugzilla->template;
|
||||
my $cgi = Bugzilla->cgi;
|
||||
|
||||
Bugzilla->login(LOGIN_REQUIRED);
|
||||
|
||||
my $type = $input->{'type'} || '';
|
||||
|
||||
if ($type eq 'status-breakdown') {
|
||||
my $case_id = trim($input->{'case_id'} || '');
|
||||
|
||||
unless ($case_id) {
|
||||
print $cgi->header;
|
||||
$vars->{'form_action'} = 'page.cgi?id=tr_case_reports.html';
|
||||
$template->process("testopia/case/choose.html.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
exit;
|
||||
}
|
||||
validate_test_id($case_id, 'case');
|
||||
|
||||
my $case = Bugzilla::Extension::Testopia::TestCase->new($case_id);
|
||||
return unless $case->canview;
|
||||
|
||||
my @data;
|
||||
my $caserun = Bugzilla::Extension::Testopia::TestCaseRun->new({});
|
||||
|
||||
my @names;
|
||||
my @values;
|
||||
foreach my $status (@{$caserun->get_status_list}) {
|
||||
push @names, $status->{'name'};
|
||||
push @values, $case->get_caserun_count($status->{'id'});
|
||||
}
|
||||
push @data, \@names;
|
||||
push @data, \@values;
|
||||
|
||||
$vars->{'width'} = 200;
|
||||
$vars->{'height'} = 150;
|
||||
$vars->{'data'} = \@data;
|
||||
$vars->{'chart_title'} = 'Historic Status Breakdown';
|
||||
$vars->{'colors'} = (['#858aef', '#56e871', '#ed3f58', '#b8eae1', '#f1d9ab', '#e17a56']);
|
||||
print $cgi->header;
|
||||
$template->process("testopia/reports/report-pie.png.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
}
|
||||
|
||||
else {
|
||||
$input->{'current_tab'} = 'case';
|
||||
$input->{'viewall'} = 1;
|
||||
### FIXME - tr_list_cases.cgi must be replaced by new code.
|
||||
my $report = Bugzilla::Extension::Testopia::Report->new('case', 'tr_list_cases.cgi', $cgi);
|
||||
$vars->{'report'} = $report;
|
||||
$vars->{'qname'} = $input->{'qname'};
|
||||
|
||||
### From Bugzilla report.cgi by Gervase Markham
|
||||
my $formatparam = $input->{'format'};
|
||||
my $report_action = $input->{'report_action'};
|
||||
if ($report_action eq "data") {
|
||||
# So which template are we using? If action is "wrap", we will be using
|
||||
# no format (it gets passed through to be the format of the actual data),
|
||||
# and either report.csv.tmpl (CSV), or report.html.tmpl (everything else).
|
||||
# report.html.tmpl produces an HTML framework for either tables of HTML
|
||||
# data, or images generated by calling report.cgi again with action as
|
||||
# "plot".
|
||||
$formatparam =~ s/[^a-zA-Z\-]//g;
|
||||
trick_taint($formatparam);
|
||||
$vars->{'format'} = $formatparam;
|
||||
$formatparam = '';
|
||||
}
|
||||
elsif ($report_action eq "plot") {
|
||||
# If action is "plot", we will be using a format as normal (pie, bar etc.)
|
||||
# and a ctype as normal (currently only png.)
|
||||
$vars->{'cumulate'} = $input->{'cumulate'} ? 1 : 0;
|
||||
$vars->{'x_labels_vertical'} = $input->{'x_labels_vertical'} ? 1 : 0;
|
||||
$vars->{'data'} = $report->{'image_data'};
|
||||
}
|
||||
else {
|
||||
ThrowUserError("unknown_action", {action => $input->{'report_action'}});
|
||||
}
|
||||
|
||||
my $format = $template->get_format("testopia/reports/report", $formatparam,
|
||||
scalar($input->{'ctype'}));
|
||||
|
||||
my @time = localtime(time());
|
||||
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
|
||||
my $filename = "report-" . $date . ".$format->{extension}";
|
||||
|
||||
my $disp = "inline";
|
||||
# We set CSV files to be downloaded, as they are designed for importing
|
||||
# into other programs.
|
||||
if ( $format->{'extension'} eq "csv" || $format->{'extension'} eq "xml" ) {
|
||||
$disp = "attachment";
|
||||
}
|
||||
|
||||
print $cgi->header( -type => $format->{'ctype'},
|
||||
-content_disposition => "$disp; filename=$filename");
|
||||
|
||||
$vars->{'time'} = $date;
|
||||
$template->process("$format->{'template'}", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,7 @@
|
||||
[%# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
# defined by the Mozilla Public License, v. 2.0.
|
||||
#%]
|
||||
@@ -21,7 +21,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Case [% case.id FILTER html %] - [% case.summary FILTER html %]</title>
|
||||
<link href="testopia/css/print.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="testopia/css/print.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
</html>
|
||||
<h1>Test Case [% case.id FILTER html %] - [% case.summary FILTER html %]</h1>
|
||||
@@ -85,7 +85,7 @@
|
||||
</table>
|
||||
<hr>
|
||||
<h3>Statistics</h3>
|
||||
<img src="tr_case_reports.cgi?case_id=[% case.id FILTER none %]&type=status-breakdown">
|
||||
<img src="page.cgi?id=tr_case_reports.html&case_id=[% case.id FILTER none %]&type=status-breakdown">
|
||||
<hr>
|
||||
<h3>Setup</h3>
|
||||
[% case.text.setup FILTER html_light %]
|
||||
|
||||
@@ -109,8 +109,8 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
[% formaturl = "$report.report_loc?$report.switchbase&width=$width&height=$height" _
|
||||
"&report_action=data" %]
|
||||
[% formaturl = "$report.report_loc&$report.switchbase&width=$width&height=$height" _
|
||||
"&report_action=data" %]
|
||||
<a href="[% formaturl %]&ctype=csv&format=table">Export as CSV</a>
|
||||
</td>
|
||||
<tr>
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
|
||||
|
||||
[% IF report %]
|
||||
<form id="case_search_form" action="tr_case_reports.cgi" method="GET">
|
||||
<form id="case_search_form" action="page.cgi" method="GET">
|
||||
<input type="hidden" name="id" value="tr_case_reports.html">
|
||||
[% PROCESS "testopia/search/report-matrix.html.tmpl"
|
||||
obj = case
|
||||
%]
|
||||
|
||||
Reference in New Issue
Block a user