From 03bc131ee178949ab2c4ef349e0805c141c4c360 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 23 Jan 2013 10:05:22 -0500 Subject: [PATCH] [SIGNED-OFF] Bug 2969 - Report Name should be mandatory for saved reports Content-Type: text/plain; charset="utf-8" This patch re-implements the database changes from the original patch and adds an update for existing reports. It also reimplements the client-side validation using the new built-in validation plugin and adds coverage for SQL reports. I have also added the "required" attribute to the SQL report textarea since saving a report with no SQL triggers an error. To test: - Create a new guided report. Confirm that you cannot save your guided report without a report name. - Create or edit a saved SQL report. Confirm that you cannot save your report without a name or without SQL. - Confirm that the saved_sql table structure has been updated. Signed-off-by: Liz Rea Functional tests pass, database tables look correct to me. Signed-off-by: Chris Cormack Even with JS disabled, the form can not be submitted without the report name filled in. However we are not checking this server side .. if this was the public interface that would be a fail. I will leave this up to the RM to decided if client side checks are ok for this. Bearing in mind we weren't handling any sql errors properly server side before this. Signed-off-by: Chris Cormack --- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 7 +++++++ .../en/modules/reports/guided_reports_start.tt | 14 +++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 54ac922..826ad7e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1874,7 +1874,7 @@ CREATE TABLE saved_sql ( -- saved sql reports `last_modified` datetime default NULL, -- the date this report was last edited `savedsql` text, -- the SQL for this report `last_run` datetime default NULL, - `report_name` varchar(255) default NULL, -- the name of this report + `report_name` varchar(255) NOT NULL default '', -- the name of this report `type` varchar(255) default NULL, -- always 1 for tabular `notes` text, -- the notes or description given to this report `cache_expiry` int NOT NULL default 300, diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index bfe5f71..91560ec 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8751,6 +8751,13 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.17.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("ALTER TABLE saved_sql CHANGE report_name report_name VARCHAR( 255 ) NOT NULL DEFAULT '' "); + print "Upgrade to $DBversion done, requiring that saved report name not be NULL. (Bug 2969: Report Name should be mandatory for saved reports)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index eebf086..fbc9c10 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -666,7 +666,7 @@ canned reports and writing custom SQL reports.

[% END %] [% IF ( save ) %] -
+ @@ -675,7 +675,7 @@ canned reports and writing custom SQL reports.

Save your custom report
    -
  1. +
  2. Required
  3. [% PROCESS group_and_subgroup_selection %]
@@ -834,13 +834,13 @@ $(document).ready(function() { load_group_subgroups(); }); - +
Create report from SQL
    -
  1. - [% IF ( reportname ) %] - [% ELSE %][% END %] +
  2. + [% IF ( reportname ) %] + [% ELSE %][% END %] Required
  3. [% PROCESS group_and_subgroup_selection %] @@ -871,7 +871,7 @@ $(document).ready(function() {
    SQL:
    - + Required
    -- 1.7.9.5