From 926f6b105f6e0dc3bceab043462be6c4d3f9863a Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sun, 8 Sep 2013 07:37:04 +0000 Subject: [PATCH] Bug 9924: (follow-up) ensure that correct error message is displayed (Apparently) unlike HTML::Template::Pro, Template Toolkit doesn't like template variables that are entirely numeric -- in conditionals, it consider them integers, most of which are Perl true. This patch changes this by setting the error variable to the error value. To test: [1] Run the test plan from the previous patch. In each case, verify that the error message is specifically applicable to the test. For example, if you try uplaoading a patron image that is larger than 500KB, the error message displayed should specifically say so. Signed-off-by: Galen Charlton --- .../prog/en/includes/patroncards-errors.inc | 26 ++++++++++---------- patroncards/edit-batch.pl | 3 +-- patroncards/image-manage.pl | 15 ++++------- patroncards/manage.pl | 3 +-- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc index e7a4c7e..136cfc4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc @@ -2,31 +2,31 @@

WARNING: - [% IF ( 101 ) %] + [% IF ( error == 101 ) %] The database returned an error while [% IF ( card_element ) %]saving [% card_element %] [% element_id %][% ELSE %]attempting a save operation[% END %]. Please have your system administrator check the error log for details. - [% ELSIF ( 102 ) %] + [% ELSIF ( error == 102 ) %] The database returned an error while [% IF ( card_element ) %]deleting [% card_element %] [% element_id %][% ELSIF ( image_ids ) %][% image_ids %][% ELSE %]attempting a delete operation[% END %]. Please have your system administrator check the error log for details. - [% ELSIF ( 201 ) %] + [% ELSIF ( error == 201 ) %] An unsupported operation was attempted[% IF ( element_id ) %] on [% card_element %] [% element_id %][% END %]. Please have your system administrator check the error log for details. - [% ELSIF ( 202 ) %] + [% ELSIF ( error == 202 ) %] An error has occurred. Please ask your system administrator to check the error log for more details. - [% ELSIF ( 203 ) %] + [% ELSIF ( error == 203 ) %] A non-existent or invalid library code was supplied. Please verify that you have a library selected. - [% ELSIF ( 301 ) %] + [% ELSIF ( error == 301 ) %] An error has occurred while attempting to upload the image file. Please ask you system administrator to check the error log for more details. - [% ELSIF ( 302 ) %] + [% ELSIF ( error == 302 ) %] Image exceeds 500KB. Please resize and import again. - [% ELSIF ( 303 ) %] + [% ELSIF ( error == 303 ) %] The database image quota currently only allows a maximum of [% image_limit %] images to be stored at any one time. Please delete one or more images to free up quota space. - [% ELSIF ( 401 ) %] + [% ELSIF ( error == 401 ) %] An error has occurred and the item(s) was not added to batch [% batch_id %]. Please have your system administrator check the error log for details. - [% ELSIF ( 402 ) %] + [% ELSIF ( error == 402 ) %] The item(s) was not added because the library is not set. Please set your library before adding items to a batch. - [% ELSIF ( 403 ) %] + [% ELSIF ( error == 403 ) %] An error has occurred and the item(s) was not removed from batch [% batch_id %]. Please have your system administrator check the error log for details. - [% ELSIF ( 404 ) %] + [% ELSIF ( error == 404 ) %] An error has occurred and batch [% batch_id %] was not deleted. Please have your system administrator check the error log for details. - [% ELSIF ( 405 ) %] + [% ELSIF ( error == 405 ) %] An error has occurred and batch [% batch_id %] not fully de-duplicated. [% ELSE %] [% END %] diff --git a/patroncards/edit-batch.pl b/patroncards/edit-batch.pl index 497c01c..b0cd3b3 100755 --- a/patroncards/edit-batch.pl +++ b/patroncards/edit-batch.pl @@ -133,8 +133,7 @@ $template->param( table_loop => $table, duplicate_message => $duplicate_message, duplicate_count => $duplicate_count, - error => ($errstr ? 1 : 0), - $errstr => 1, + error => $errstr, ); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/patroncards/image-manage.pl b/patroncards/image-manage.pl index f9f7eac..cf5257a 100755 --- a/patroncards/image-manage.pl +++ b/patroncards/image-manage.pl @@ -54,8 +54,7 @@ if ($op eq 'upload') { SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, - error => 1, - $errstr => 1, + error => $errstr, ); } else { @@ -69,8 +68,7 @@ if ($op eq 'upload') { SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, - error => 1, - $errstr => 1, + error => $errstr, ); } else { @@ -87,8 +85,7 @@ if ($op eq 'upload') { SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, - error => 1, - $errstr => 1, + error => $errstr, image_limit => $image_limit, ); } @@ -120,8 +117,7 @@ elsif ($op eq 'delete') { DELETE_SUCCESSFULL => 0, IMAGE_IDS => join(', ', @image_ids), TABLE => $table, - error => 1, - $errstr => 1, + error => $errstr, image_ids => join(',',@image_ids), ); } @@ -149,8 +145,7 @@ else { # to trap unsupported operations SOURCE_FILE => $source_file, IMAGE_NAME => $image_name, TABLE => $table, - error => 1, - $errstr => 1, + error => $errstr, ); } diff --git a/patroncards/manage.pl b/patroncards/manage.pl index 2af8c0e..13b574b 100755 --- a/patroncards/manage.pl +++ b/patroncards/manage.pl @@ -101,8 +101,7 @@ my $table = html_table($display_columns->{$card_element}, $db_rows); $template->param(print => 1) if ($card_element eq 'batch'); $template->param( - error => ($errstr ? 1 : 0), - $errstr => 1, + error => $errstr, ); $template->param( op => $op, -- 1.7.10.4