From 9f753799d8f644f0d3706574583a817ffda58bf9 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 18 Sep 2015 16:01:20 +0200 Subject: [PATCH] Bug 14321: [QA Follow-up] Additional QA requests This patch makes following requested changes: [1] Renamed categorycode to uploadcategorycode (with atomicupdate file) [2] Confirmation before deleting an uploaded file [3] Label for Public checkbox can be clicked [4] Back button on result list (not in plugin mode) [5] Correct additional variable interpolation from sql queries Signed-off-by: Marcel de Rooy Tested the db revision, unit test. Uploaded temporary and permanent file, incl. plugin mode. Deleted an upload. Ran stage-marc-import.pl. Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- Koha/Upload.pm | 16 +++++------ .../mysql/atomicupdate/14321b_category.sql | 1 + installer/data/mysql/kohastructure.sql | 2 +- .../prog/en/modules/tools/upload.tt | 27 ++++++++++++++++--- t/db_dependent/Upload.t | 6 ++--- 5 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/14321b_category.sql diff --git a/Koha/Upload.pm b/Koha/Upload.pm index e8787fa55d..90f93e796f 100644 --- a/Koha/Upload.pm +++ b/Koha/Upload.pm @@ -170,7 +170,7 @@ sub get { my ( @rv, $res); foreach my $r ( @$temp ) { undef $res; - foreach( qw[id hashvalue filesize categorycode public permanent] ) { + foreach( qw[id hashvalue filesize uploadcategorycode public permanent] ) { $res->{$_} = $r->{$_}; } $res->{name} = $r->{filename}; @@ -340,8 +340,8 @@ sub _done { sub _register { my ( $self, $filename, $size ) = @_; my $dbh= C4::Context->dbh; - my $sql= "INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, - owner, categorycode, public, permanent) VALUES (?,?,?,?,?,?,?,?)"; + my $sql= 'INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, + owner, uploadcategorycode, public, permanent) VALUES (?,?,?,?,?,?,?,?)'; my @pars= ( $self->{files}->{$filename}->{hash}, $filename, @@ -361,24 +361,24 @@ sub _lookup { my ( $self, $params ) = @_; my $dbh = C4::Context->dbh; my $sql = q| -SELECT id,hashvalue,filename,dir,filesize,categorycode,public,permanent +SELECT id,hashvalue,filename,dir,filesize,uploadcategorycode,public,permanent FROM uploaded_files |; my @pars; if( $params->{id} ) { return [] if $params->{id} !~ /^\d+(,\d+)*$/; - $sql.= "WHERE id IN ($params->{id})"; + $sql.= 'WHERE id IN ('.$params->{id}.')'; @pars = (); } elsif( $params->{hashvalue} ) { - $sql.= "WHERE hashvalue=?"; + $sql.= 'WHERE hashvalue=?'; @pars = ( $params->{hashvalue} ); } elsif( $params->{term} ) { - $sql.= "WHERE (filename LIKE ? OR hashvalue LIKE ?)"; + $sql.= 'WHERE (filename LIKE ? OR hashvalue LIKE ?)'; @pars = ( '%'.$params->{term}.'%', '%'.$params->{term}.'%' ); } else { return []; } - $sql.= $self->{public}? " AND public=1": ''; + $sql.= $self->{public}? ' AND public=1': ''; $sql.= ' ORDER BY id'; my $temp= $dbh->selectall_arrayref( $sql, { Slice => {} }, @pars ); return $temp; diff --git a/installer/data/mysql/atomicupdate/14321b_category.sql b/installer/data/mysql/atomicupdate/14321b_category.sql new file mode 100644 index 0000000000..37e251ce43 --- /dev/null +++ b/installer/data/mysql/atomicupdate/14321b_category.sql @@ -0,0 +1 @@ +ALTER TABLE uploaded_files CHANGE COLUMN categorycode uploadcategorycode tinytext; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 21c6d6c1e7..be15117972 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3359,7 +3359,7 @@ CREATE TABLE uploaded_files ( dir TEXT NOT NULL, filesize int(11), dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - categorycode tinytext, + uploadcategorycode tinytext, owner int(11), public tinyint, permanent tinyint, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt index 44b8c0b1c0..6e20a8f6e7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt @@ -70,9 +70,8 @@ [% IF plugin %] [% ELSE %] - + - Allow public downloads [% END %] @@ -133,6 +132,16 @@ [% END %] [% END %] +[% BLOCK back %] + [% IF !plugin %] +
+
+ +
+
+ [% END %] +[% END %] + [% BLOCK newsearch %]
@@ -163,7 +172,7 @@ [% record.name %] [% record.filesize %] [% record.hashvalue %] - [% record.categorycode %] + [% record.uploadcategorycode %] [% IF !plugin %] [% IF record.public %]Yes[% ELSE %]No[% END %] [% IF record.permanent %]No[% ELSE %]Yes[% END %] @@ -173,7 +182,7 @@ Choose  [% END %] Download  - Delete + Delete [% END %] @@ -279,6 +288,12 @@ function SubmitMe(op, id, msg ) { $("#submitter #msg").val( msg ); $("#submitter").submit(); } +function DeleteEntry(id) { + if( !confirm( _("Do you really want to delete this upload?") )) + return false; + ClearField(); + SubmitMe( 'delete', id ); +} function ClearField() { [% IF plugin %] $(window.opener.document).find('#[% index %]').val( '' ); @@ -298,6 +313,9 @@ $(document).ready(function() { ShowAlerts( [% msg %] ); [% END %] $("#fileuploadcancel").hide(); + $("#public_cb").click(function() { + $("#public").click(); + }); }); //]]> @@ -329,6 +347,7 @@ $(document).ready(function() {

Your request gave the following results:

[% PROCESS table_results %] [% PROCESS closer %] + [% PROCESS back %] [% ELSE %]

Sorry, your request had no results.

[% PROCESS newsearch %] diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t index d8180348a3..c73675d7e1 100644 --- a/t/db_dependent/Upload.t +++ b/t/db_dependent/Upload.t @@ -96,7 +96,7 @@ sub test01 { is( $upl->count, 2, 'Count returns 2 also' ); foreach my $r ( $upl->get({ id => $res }) ) { if( $r->{name} eq 'file1' ) { - is( $r->{categorycode}, 'A', 'Check category A' ); + is( $r->{uploadcategorycode}, 'A', 'Check category A' ); is( $r->{filesize}, 6000, 'Check size of file1' ); } elsif( $r->{name} eq 'file2' ) { is( $r->{filesize}, 8000, 'Check size of file2' ); @@ -115,7 +115,7 @@ sub test02 { is( $upl->count, 1, 'Upload 2 includes one file' ); my $res= $upl->result; my $r = $upl->get({ id => $res, filehandle => 1 }); - is( $r->{categorycode}, 'B', 'Check category B' ); + is( $r->{uploadcategorycode}, 'B', 'Check category B' ); is( $r->{public}, 1, 'Check public == 1' ); is( ref($r->{fh}) eq 'IO::File' && $r->{fh}->opened, 1, 'Get returns a file handle' ); } @@ -125,7 +125,7 @@ sub test03 { my $cgi= $upl->cgi; is( $upl->count, 1, 'Upload 3 includes one temporary file' ); my $r = $upl->get({ id => $upl->result }); - is( $r->{categorycode}, 'koha_upload', 'Check category temp file' ); + is( $r->{uploadcategorycode}, 'koha_upload', 'Check category temp file' ); } sub test04 { # Fail on a file already there -- 2.39.5