Commit cc989876 authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 232749 - fix various charting problems revealed by b.m.o. upgrade, including…

Bug 232749 - fix various charting problems revealed by b.m.o. upgrade, including editing, subscribe buttons and terminology. Patch by gerv; r=kiko, a=justdave.
parent ecdfa3b6
...@@ -47,9 +47,14 @@ sub new { ...@@ -47,9 +47,14 @@ sub new {
my $arg_count = scalar(@_); my $arg_count = scalar(@_);
# There are three ways of creating Series objects. Two (CGI and Parameters)
# are for use when creating a new series. One (Database) is for retrieving
# information on existing series.
if ($arg_count == 1) { if ($arg_count == 1) {
if (ref($_[0])) { if (ref($_[0])) {
# We've been given a CGI object to create a new Series from. # We've been given a CGI object to create a new Series from.
# This series may already exist - external code needs to check
# before it calls writeToDatabase().
$self->initFromCGI($_[0]); $self->initFromCGI($_[0]);
} }
else { else {
...@@ -60,6 +65,8 @@ sub new { ...@@ -60,6 +65,8 @@ sub new {
} }
elsif ($arg_count >= 6 && $arg_count <= 8) { elsif ($arg_count >= 6 && $arg_count <= 8) {
# We've been given a load of parameters to create a new Series from. # We've been given a load of parameters to create a new Series from.
# Currently, undef is always passed as the first parameter; this allows
# you to call writeToDatabase() unconditionally.
$self->initFromParameters(@_); $self->initFromParameters(@_);
} }
else { else {
...@@ -146,7 +153,6 @@ sub initFromCGI { ...@@ -146,7 +153,6 @@ sub initFromCGI {
sub writeToDatabase { sub writeToDatabase {
my $self = shift; my $self = shift;
# Lock some tables
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
$dbh->do("LOCK TABLES series_categories WRITE, series WRITE, " . $dbh->do("LOCK TABLES series_categories WRITE, series WRITE, " .
"user_series_map WRITE"); "user_series_map WRITE");
...@@ -154,8 +160,15 @@ sub writeToDatabase { ...@@ -154,8 +160,15 @@ sub writeToDatabase {
my $category_id = getCategoryID($self->{'category'}); my $category_id = getCategoryID($self->{'category'});
my $subcategory_id = getCategoryID($self->{'subcategory'}); my $subcategory_id = getCategoryID($self->{'subcategory'});
my $exists;
if ($self->{'series_id'}) {
$exists =
$dbh->selectrow_array("SELECT series_id FROM series
WHERE series_id = $self->{'series_id'}");
}
# Is this already in the database? # Is this already in the database?
if ($self->existsInDatabase()) { if ($exists) {
# Update existing series # Update existing series
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
$dbh->do("UPDATE series SET " . $dbh->do("UPDATE series SET " .
...@@ -196,7 +209,7 @@ sub writeToDatabase { ...@@ -196,7 +209,7 @@ sub writeToDatabase {
} }
# Check whether a series with this name, category and subcategory exists in # Check whether a series with this name, category and subcategory exists in
# the DB and, if so, sets series_id to its series_id. # the DB and, if so, returns its series_id.
sub existsInDatabase { sub existsInDatabase {
my $self = shift; my $self = shift;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
...@@ -205,12 +218,12 @@ sub existsInDatabase { ...@@ -205,12 +218,12 @@ sub existsInDatabase {
my $subcategory_id = getCategoryID($self->{'subcategory'}); my $subcategory_id = getCategoryID($self->{'subcategory'});
trick_taint($self->{'name'}); trick_taint($self->{'name'});
$self->{'series_id'} = $dbh->selectrow_array("SELECT series_id " . my $series_id = $dbh->selectrow_array("SELECT series_id " .
"FROM series WHERE category = $category_id " . "FROM series WHERE category = $category_id " .
"AND subcategory = $subcategory_id AND name = " . "AND subcategory = $subcategory_id AND name = " .
$dbh->quote($self->{'name'})); $dbh->quote($self->{'name'}));
return(defined($self->{'series_id'})); return($series_id);
} }
# Get a category or subcategory IDs, creating the category if it doesn't exist. # Get a category or subcategory IDs, creating the category if it doesn't exist.
......
...@@ -275,12 +275,14 @@ if ($::FORM{'cmdtype'} eq "dorem") { ...@@ -275,12 +275,14 @@ if ($::FORM{'cmdtype'} eq "dorem") {
if ($::FORM{'remaction'} eq "run") { if ($::FORM{'remaction'} eq "run") {
$::buffer = LookupNamedQuery($::FORM{"namedcmd"}); $::buffer = LookupNamedQuery($::FORM{"namedcmd"});
$vars->{'searchname'} = $::FORM{'namedcmd'}; $vars->{'searchname'} = $::FORM{'namedcmd'};
$vars->{'searchtype'} = "saved";
$params = new Bugzilla::CGI($::buffer); $params = new Bugzilla::CGI($::buffer);
$order = $params->param('order') || $order; $order = $params->param('order') || $order;
} }
elsif ($::FORM{'remaction'} eq "runseries") { elsif ($::FORM{'remaction'} eq "runseries") {
$::buffer = LookupSeries($::FORM{"series_id"}); $::buffer = LookupSeries($::FORM{"series_id"});
$vars->{'searchname'} = $::FORM{'namedcmd'}; $vars->{'searchname'} = $::FORM{'namedcmd'};
$vars->{'searchtype'} = "series";
$params = new Bugzilla::CGI($::buffer); $params = new Bugzilla::CGI($::buffer);
$order = $params->param('order') || $order; $order = $params->param('order') || $order;
} }
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
# Contributor(s): Gervase Markham <gerv@gerv.net> # Contributor(s): Gervase Markham <gerv@gerv.net>
# Glossary: # Glossary:
# series: An individual, defined set of data plotted over time. # series: An individual, defined set of data plotted over time.
# line: A set of one or more series, to be summed and drawn as a single # data set: What a series is called in the UI.
# line when the series is plotted. # line: A set of one or more series, to be summed and drawn as a single
# chart: A set of lines # line when the series is plotted.
# chart: A set of lines
#
# So when you select rows in the UI, you are selecting one or more lines, not # So when you select rows in the UI, you are selecting one or more lines, not
# series. # series.
...@@ -34,7 +36,6 @@ ...@@ -34,7 +36,6 @@
# Broken image on error or no data - need to do much better. # Broken image on error or no data - need to do much better.
# Centralise permission checking, so UserInGroup('editbugs') not scattered # Centralise permission checking, so UserInGroup('editbugs') not scattered
# everywhere. # everywhere.
# Better protection on collectstats.pl for second run in a day
# User documentation :-) # User documentation :-)
# #
# Bonus: # Bonus:
...@@ -84,6 +85,9 @@ ConnectToDatabase(); ...@@ -84,6 +85,9 @@ ConnectToDatabase();
confirm_login(); confirm_login();
# Only admins may create public queries
UserInGroup('admin') || $cgi->delete('public');
# All these actions relate to chart construction. # All these actions relate to chart construction.
if ($action =~ /^(assemble|add|remove|sum|subscribe|unsubscribe)$/) { if ($action =~ /^(assemble|add|remove|sum|subscribe|unsubscribe)$/) {
# These two need to be done before the creation of the Chart object, so # These two need to be done before the creation of the Chart object, so
...@@ -120,6 +124,7 @@ elsif ($action eq "wrap") { ...@@ -120,6 +124,7 @@ elsif ($action eq "wrap") {
} }
elsif ($action eq "create") { elsif ($action eq "create") {
assertCanCreate($cgi); assertCanCreate($cgi);
my $series = new Bugzilla::Series($cgi); my $series = new Bugzilla::Series($cgi);
if (!$series->existsInDatabase()) { if (!$series->existsInDatabase()) {
...@@ -127,7 +132,7 @@ elsif ($action eq "create") { ...@@ -127,7 +132,7 @@ elsif ($action eq "create") {
$vars->{'message'} = "series_created"; $vars->{'message'} = "series_created";
} }
else { else {
$vars->{'message'} = "series_already_exists"; ThrowUserError("series_already_exists", {'series' => $series});
} }
$vars->{'series'} = $series; $vars->{'series'} = $series;
...@@ -150,7 +155,20 @@ elsif ($action eq "alter") { ...@@ -150,7 +155,20 @@ elsif ($action eq "alter") {
assertCanEdit($series_id); assertCanEdit($series_id);
my $series = new Bugzilla::Series($cgi); my $series = new Bugzilla::Series($cgi);
# We need to check if there is _another_ series in the database with
# our (potentially new) name. So we call existsInDatabase() to see if
# the return value is us or some other series we need to avoid stomping
# on.
my $id_of_series_in_db = $series->existsInDatabase();
if (defined($id_of_series_in_db) &&
$id_of_series_in_db != $series->{'series_id'})
{
ThrowUserError("series_already_exists", {'series' => $series});
}
$series->writeToDatabase(); $series->writeToDatabase();
$vars->{'changes_saved'} = 1;
edit($series); edit($series);
} }
...@@ -193,9 +211,6 @@ sub assertCanCreate { ...@@ -193,9 +211,6 @@ sub assertCanCreate {
UserInGroup("editbugs") || ThrowUserError("illegal_series_creation"); UserInGroup("editbugs") || ThrowUserError("illegal_series_creation");
# Only admins may create public queries
UserInGroup('admin') || $cgi->delete('public');
# Check permission for frequency # Check permission for frequency
my $min_freq = 7; my $min_freq = 7;
if ($cgi->param('frequency') < $min_freq && !UserInGroup("admin")) { if ($cgi->param('frequency') < $min_freq && !UserInGroup("admin")) {
...@@ -231,25 +246,7 @@ sub edit { ...@@ -231,25 +246,7 @@ sub edit {
$vars->{'category'} = Bugzilla::Chart::getVisibleSeries(); $vars->{'category'} = Bugzilla::Chart::getVisibleSeries();
$vars->{'creator'} = new Bugzilla::User($series->{'creator'}); $vars->{'creator'} = new Bugzilla::User($series->{'creator'});
$vars->{'default'} = $series;
# If we've got any parameters, use those in preference to the values
# read from the database. This is a bit ugly, but I can't see a better
# way to make this work in the no-JS situation.
if ($cgi->param('category'))
{
$vars->{'default'} = new Bugzilla::Series($series->{'series_id'},
$cgi->param('category') || $series->{'category'},
$cgi->param('subcategory') || $series->{'subcategory'},
$cgi->param('name') || $series->{'name'},
$series->{'creator'},
$cgi->param('frequency') || $series->{'frequency'});
$vars->{'default'}{'public'}
= $cgi->param('public') || $series->{'public'};
}
else {
$vars->{'default'} = $series;
}
print "Content-Type: text/html\n\n"; print "Content-Type: text/html\n\n";
$template->process("reports/edit-series.html.tmpl", $vars) $template->process("reports/edit-series.html.tmpl", $vars)
......
...@@ -135,17 +135,6 @@ ...@@ -135,17 +135,6 @@
<a href="editflagtypes.cgi">Back to flag types.</a> <a href="editflagtypes.cgi">Back to flag types.</a>
</p> </p>
[% ELSIF message_tag == "series_already_exists" %]
[% title = "Series Already Exists" %]
A series <em>[% series.category FILTER html %] /
[%+ series.subcategory FILTER html %] /
[%+ series.name FILTER html %]</em>
already exists. If you want to create this series, you will need to give
it a different name.
<br><br>
Go back or
<a href="query.cgi?format=create-series">create another series</a>.
[% ELSIF message_tag == "series_created" %] [% ELSIF message_tag == "series_created" %]
[% title = "Series Created" %] [% title = "Series Created" %]
The series <em>[% series.category FILTER html %] / The series <em>[% series.category FILTER html %] /
......
...@@ -657,6 +657,13 @@ ...@@ -657,6 +657,13 @@
[% title = "Access Denied" %] [% title = "Access Denied" %]
You do not have the permissions necessary to run a sanity check. You do not have the permissions necessary to run a sanity check.
[% ELSIF error == "series_already_exists" %]
[% title = "Series Already Exists" %]
A series named <em>[% series.category FILTER html %] /
[%+ series.subcategory FILTER html %] /
[%+ series.name FILTER html %]</em>
already exists.
[% ELSIF error == "sidebar_supports_mozilla_only" %] [% ELSIF error == "sidebar_supports_mozilla_only" %]
Sorry - sidebar.cgi currently only supports Mozilla based web browsers. Sorry - sidebar.cgi currently only supports Mozilla based web browsers.
<a href="http://www.mozilla.org">Upgrade today</a>. :-) <a href="http://www.mozilla.org">Upgrade today</a>. :-)
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
# Contributor(s): Myk Melez <myk@mozilla.org> # Contributor(s): Myk Melez <myk@mozilla.org>
#%] #%]
[%# INTERFACE:
# searchtype: string. Type of search - either "series", "saved" or undef.
# ...
#%]
[%############################################################################%] [%############################################################################%]
[%# Template Initialization #%] [%# Template Initialization #%]
[%############################################################################%] [%############################################################################%]
...@@ -155,7 +160,7 @@ ...@@ -155,7 +160,7 @@
<a href="query.cgi?[% urlquerypart FILTER html %]">Edit&nbsp;Search</a> <a href="query.cgi?[% urlquerypart FILTER html %]">Edit&nbsp;Search</a>
</td> </td>
[% IF searchname %] [% IF searchtype == "saved" %]
<td valign="middle" nowrap="nowrap"> <td valign="middle" nowrap="nowrap">
| |
<a href="buglist.cgi?cmdtype=dorem&amp;remaction=forget&amp;namedcmd= <a href="buglist.cgi?cmdtype=dorem&amp;remaction=forget&amp;namedcmd=
......
...@@ -190,7 +190,7 @@ function subcatSelected() { ...@@ -190,7 +190,7 @@ function subcatSelected() {
</td> </td>
<td align="center"> <td align="center">
[% IF series.creator != 0 %] [% IF NOT series.public %]
[% IF series.isSubscribed(user.id) %] [% IF series.isSubscribed(user.id) %]
<input type="submit" value="Unsubscribe" style="width: 12ex;" <input type="submit" value="Unsubscribe" style="width: 12ex;"
name="action-unsubscribe[% series.series_id %]"> name="action-unsubscribe[% series.series_id %]">
......
...@@ -28,12 +28,19 @@ ...@@ -28,12 +28,19 @@
[% PROCESS global/header.html.tmpl %] [% PROCESS global/header.html.tmpl %]
[% IF changes_saved %]
<p>
<font color="red">
Series updated.
</font>
</p>
[% END %]
<form method="get" action="chart.cgi" name="chartform"> <form method="get" action="chart.cgi" name="chartform">
[% button_name = "Change" %] [% PROCESS reports/series.html.tmpl
button_name = "Change Data Set" %]
[% PROCESS reports/series.html.tmpl %] <input type="hidden" name="action" value="alter">
<input type="hidden" name="action-alter" value="1">
[% IF default.series_id %] [% IF default.series_id %]
<input type="hidden" name="series_id" value="[% default.series_id %]"> <input type="hidden" name="series_id" value="[% default.series_id %]">
...@@ -50,8 +57,12 @@ ...@@ -50,8 +57,12 @@
[% END %] [% END %]
</p> </p>
<p>Note: it is not yet possible to edit the search associated with this data
set.
</p>
<p> <p>
<a href="query.cgi?[% default.query FILTER html%]">View <a href="query.cgi?[% default.query FILTER html %]">View
series search parameters</a> | series search parameters</a> |
<a href="buglist.cgi?cmdtype=dorem&amp;namedcmd= <a href="buglist.cgi?cmdtype=dorem&amp;namedcmd=
[% default.category FILTER url_quote %]- [% default.category FILTER url_quote %]-
......
...@@ -86,14 +86,9 @@ ...@@ -86,14 +86,9 @@
</td> </td>
<td></td> <td></td>
<td> <td>
<input type="submit" name="action-create" value="Create Data Set"> <input type="submit" name="submit-button"
value="[% button_name FILTER html %]">
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<script language="JavaScript" type="text/javascript">
document.chartform.category[0].selected = true;
catSelected();
checkNewState();
</script>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<p style="color: red"> <p style="color: red">
Note: there is currently a restriction that data sets will only count public Note: there is currently a restriction that data sets will only count public
[% terms.bugs %] (those not in any group). [%+ terms.bugs %] (those not in any group).
</p> </p>
<form method="get" action="chart.cgi" name="chartform"> <form method="get" action="chart.cgi" name="chartform">
...@@ -43,12 +43,20 @@ ...@@ -43,12 +43,20 @@
<p> <p>
<input type="submit" name="action-search" value="Run Search"> <input type="submit" name="action-search" value="Run Search">
to see which [% terms.bugs %] would be included in this series. to see which [% terms.bugs %] would be included in this data set.
</p> </p>
<h3>Data Set Parameters</h3> <h3>Data Set Parameters</h3>
[% INCLUDE reports/series.html.tmpl %] [% PROCESS reports/series.html.tmpl
button_name = "Create Data Set" %]
<input type="hidden" name="action" value="create">
<script language="JavaScript" type="text/javascript">
document.chartform.category[0].selected = true;
catSelected();
checkNewState();
</script>
<hr> <hr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment