Added rudimentary saved search support. NEEDS TESTING!

git-svn-id: svn://10.0.0.236/trunk@218038 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ghendricks%novell.com 2007-01-09 00:41:23 +00:00
parent 35d51963b5
commit 91cfe2e35d
13 changed files with 155 additions and 4 deletions

View File

@ -36,6 +36,7 @@
<div class="links">
<a href="tr_query.cgi">Search</a>&nbsp;|&nbsp;
<a href="tr_query.cgi?report=1">Reports</a>&nbsp;|&nbsp;
[% IF user.login %]
<a href="tr_new_plan.cgi">New Plan</a>&nbsp;|&nbsp;
<a href="tr_new_case.cgi?plan_id=[% plan_id FILTER none %]">New Case</a>&nbsp;|&nbsp;
<a href="tr_new_run.cgi?plan_id=[% plan_id FILTER none %]&case_status_id=2">New Run</a>&nbsp;|&nbsp;
@ -44,17 +45,26 @@
[% IF UserInGroup('admin') %]
<a href="tr_admin.cgi">Admin</a>&nbsp;|&nbsp;
[% END %]
[% END %]
<a href="testopia/doc/Manual.pdf" target="_blank">Help</a>
<br />
[% IF user.login %]
[% IF user.login %]
<a href="tr_list_runs.cgi?current_tab=run&run_status=0">Current Runs</a>&nbsp;|&nbsp;
<a href="tr_list_plans.cgi?current_tab=plan&name_type=allwordssubstr&name=&plan_text_type=allwordssubstr&plan_text=&tag_type=allwords&tags=&author_type=exact&author=[% user.login FILTER url_quote %]&plan_id=">My Plans</a>&nbsp;|&nbsp;
<a href="tr_list_cases.cgi?current_tab=case&summary_type=allwordssubstr&summary=&tcaction_type=allwordssubstr&tcaction=&tceffect_type=allwordssubstr&tceffect=&script_type=allwordssubstr&script=&requirement_type=allwordssubstr&requirement=&tag_type=allwords&tags=&author_type=exact&author=&default_tester_type=substring&default_tester=[% user.login FILTER url_quote %]&case_id=&plan_id=">My Cases</a>&nbsp;|&nbsp;
<a href="tr_list_runs.cgi?current_tab=run&summary_type=allwordssubstr&summary=&notes_type=allwordssubstr&notes=&environment_type=allwordssubstr&environment=&tag_type=allwords&tag=&manager_type=substring&manager=[% user.login FILTER url_quote %]&run_id=&plan_id=&assignee_type=substr&assignee=[% user.login FILTER url_quote %]">My Runs</a>
[% END %]&nbsp;|&nbsp;
[% END %]&nbsp;|&nbsp;
<form action="tr_quicksearch.cgi">
<input name="query" size="25" />
<input type="submit" value="Find" />
</form>
</div>
[% IF user.login %]
<div class="links">
<b>Testopia Saved Searches:</b>
[% FOREACH query = user.testopia_queries %]
<a href="[% query.query %]">[% query.name %]</a>[% '&nbsp;|&nbsp;' UNLESS loop.last %]
[% END %]
</div>
[% END %]
</div>

View File

@ -207,8 +207,9 @@ found.
<a href="tr_list_cases.cgi?[% urlquerypart FILTER remove('&viewall=.') FILTER html %]&amp;ctype=xml&amp;viewall=1"><image src="testopia/img/xml.png" class="image"></a>
</div>
</div>
[% END %]
[% END %]
[% PROCESS "testopia/saved-search.html.tmpl" %]
[%############################################################################%]
[%# Page Footer #%]
[%############################################################################%]

View File

@ -108,9 +108,9 @@ found.
<input TYPE="SUBMIT" name="action" class="tr_button" VALUE="Commit">
</p>
[% END %]
</form>
[% PROCESS "testopia/saved-search.html.tmpl" %]
[%############################################################################%]
[%# Page Footer #%]
[%############################################################################%]

View File

@ -116,6 +116,7 @@ found.
[% END %]
</form>
[% PROCESS "testopia/saved-search.html.tmpl" %]
[%############################################################################%]
[%# Page Footer #%]
[%############################################################################%]

View File

@ -0,0 +1,32 @@
[%# 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 System.
#
# The Initial Developer of the Original Code is Greg Hendricks.
# Portions created by Greg Hendricks are Copyright (C) 2001
# Greg Hendricks. All Rights Reserved.
#
# Contributor(s): Greg Hendricks <ghendricks@novell.com>
#%]
<div id="testopia_save_search">
[% IF qname %]
<a href="tr_query.cgi?action=delete_query&query_name=[% qname %]">Delete saved query [% qname FILTER html %]</a>
[% ELSE %]
<form action="tr_query.cgi" method="POST">
<input type="hidden" name="query_part" value="[% table.get_url %][% table.get_query_part %]">
<input type="hidden" name="action" value="save_query">
<input type="submit" value="Save Search"> as
<input name="query_name">
</form>
[% END %]
</div>

View File

@ -88,6 +88,29 @@ Index: /bmo-2.22/Bugzilla.pm
];
# Non-cgi scripts that should silently exit.
Index: /bmo-2.22/Bugzilla/User.pm
===================================================================
RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/User.pm,v
retrieving revision 1.101.2.3
diff -u -r1.101.2.3 User.pm
--- /bmo-2.22/Bugzilla/User.pm 14 Mar 2006 07:45:54 -0000 1.101.2.3
+++ /bmo-2.22-testopia/Bugzilla/User.pm 9 Jan 2007 00:35:14 -0000
@@ -236,6 +236,16 @@
return $self->{queries};
}
+sub testopia_queries {
+ my $self = shift;
+ my $dbh = Bugzilla->dbh;
+ my $ref = $dbh->selectall_arrayref(
+ "SELECT name, query FROM test_named_queries
+ WHERE userid = ? AND isvisible = 1",
+ {'Slice' =>{}}, $self->id);
+ return $ref;
+}
+
sub settings {
my ($self) = @_;
Index: /bmo-2.22/Bugzilla/DB/Schema.pm
===================================================================
--- /bmo-2.22/Bugzilla/DB/Schema.pm 2006-01-06 07:38:42.000000000 -0700

View File

@ -88,6 +88,30 @@ Index: /bmo-2.22/Bugzilla.pm
];
# Non-cgi scripts that should silently exit.
Index: /bmo-2.22/Bugzilla/User.pm
===================================================================
RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/User.pm,v
retrieving revision 1.101.2.5
diff -u -r1.101.2.5 User.pm
--- /bmo-2.22/Bugzilla/User.pm 14 Oct 2006 21:07:19 -0000 1.101.2.5
+++ /bmo-2.22-testopia/Bugzilla/User.pm 9 Jan 2007 00:38:05 -0000
@@ -236,6 +236,16 @@
return $self->{queries};
}
+sub testopia_queries {
+ my $self = shift;
+ my $dbh = Bugzilla->dbh;
+ my $ref = $dbh->selectall_arrayref(
+ "SELECT name, query FROM test_named_queries
+ WHERE userid = ? AND isvisible = 1",
+ {'Slice' =>{}}, $self->id);
+ return $ref;
+}
+
sub settings {
my ($self) = @_;
Index: /bmo-2.22/Bugzilla/DB/Schema.pm
===================================================================
--- /bmo-2.22/Bugzilla/DB/Schema.pm 2006-01-06 07:38:42.000000000 -0700

View File

@ -237,6 +237,8 @@ elsif ($action eq 'do_delete'){
exit;
}
$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname');
# 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);

View File

@ -245,6 +245,9 @@ if ($action eq 'Commit'){
###############
### Display ###
###############
$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname');
# Take the search from the URL params and convert it to SQL
$cgi->param('current_tab', 'case');
my $search = Bugzilla::Testopia::Search->new($cgi);

View File

@ -46,6 +46,8 @@ print $cgi->header;
my $action = $cgi->param('action') || '';
$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname');
$cgi->param('current_tab', 'environment');
my $search = Bugzilla::Testopia::Search->new($cgi);
my $table = Bugzilla::Testopia::Table->new('environment', 'tr_list_environments.cgi', $cgi, undef, $search->query);

View File

@ -132,6 +132,7 @@ if ($action eq 'Commit'){
}
else {
$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname');
$cgi->param('current_tab', 'plan');
my $search = Bugzilla::Testopia::Search->new($cgi);
my $table = Bugzilla::Testopia::Table->new('plan', 'tr_list_plans.cgi', $cgi, undef, $search->query);

View File

@ -144,6 +144,7 @@ if ($action eq 'Commit'){
}
else {
$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname');
$cgi->param('current_tab', 'run');
my $search = Bugzilla::Testopia::Search->new($cgi);
my $table = Bugzilla::Testopia::Table->new('run', 'tr_list_runs.cgi', $cgi, undef, $search->query);

View File

@ -27,6 +27,7 @@ use lib ".";
use Bugzilla;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Constants;
use Bugzilla::Testopia::Util;
use Bugzilla::Testopia::TestPlan;
use Bugzilla::Testopia::TestRun;
@ -185,7 +186,57 @@ elsif ($action eq 'get_valid_exp'){
chop($ret);
print $ret;
}
elsif ($action eq 'save_query'){
Bugzilla->login(LOGIN_REQUIRED);
my $query = $cgi->param('query_part');
my $qname = $cgi->param('query_name');
ThrowUserError('query_name_missing') unless $qname;
trick_taint($query);
trick_taint($qname);
my ($name) = $dbh->selectrow_array(
"SELECT name
FROM test_named_queries
WHERE userid = ?
AND name = ?",
undef,(Bugzilla->user->id, $qname));
if ($name){
$dbh->do(
"UPDATE test_named_queries
SET query = ?
WHERE userid = ?
AND name = ?",
undef,($query, Bugzilla->user->id, $qname));
$vars->{'tr_message'} = "Updated saved search '$qname'";
}
else{
$query .= "&qname=$qname";
$dbh->do("INSERT INTO test_named_queries
VALUES(?,?,?,?)",
undef, (Bugzilla->user->id, $qname, 1, $query));
$vars->{'tr_message'} = "Search saved as '$qname'";
}
display();
}
elsif ($action eq 'delete_query'){
my $qname = $cgi->param('query_name');
trick_taint($qname);
$dbh->do("DELETE FROM test_named_queries WHERE userid = ? AND name = ?",
undef, (Bugzilla->user->id, $qname));
$vars->{'tr_message'} = "Testopia Saved Search '$qname' Deleted";
display();
}
else{
display();
}
sub display {
my $plan = Bugzilla::Testopia::TestPlan->new({ 'plan_id' => 0 });
my @allversions;
foreach my $p (@{$plan->get_available_products}){