Bugzilla – Attachment 42707 Details for
Bug 14321
Merge UploadedFile and UploadedFiles into Koha::Upload
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14321: [QA Follow-up] Additional QA requests
Bug-14321-QA-Follow-up-Additional-QA-requests.patch (text/plain), 8.47 KB, created by
Marcel de Rooy
on 2015-09-18 14:21:44 UTC
(
hide
)
Description:
Bug 14321: [QA Follow-up] Additional QA requests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-09-18 14:21:44 UTC
Size:
8.47 KB
patch
obsolete
>From ac0ac62439911d9227511b309f2ee5af30761939 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 18 Sep 2015 16:01:20 +0200 >Subject: [PATCH] Bug 14321: [QA Follow-up] Additional QA requests >Content-Type: text/plain; charset=utf-8 > >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 <m.de.rooy@rijksmuseum.nl> >Tested the db revision, unit test. >Uploaded temporary and permanent file, incl. plugin mode. >Deleted an upload. >Ran stage-marc-import.pl. >--- > Koha/Upload.pm | 16 ++++++------ > .../data/mysql/atomicupdate/14321b_category.sql | 1 + > installer/data/mysql/kohastructure.sql | 2 +- > .../intranet-tmpl/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 e8787fa..90f93e7 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 0000000..37e251c >--- /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 21c6d6c..be15117 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 44b8c0b..6e20a8f 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 %] > <input type="hidden" id="public" name="public" value="1"/> > [% ELSE %] >- <label> </label> >+ <label id="public_cb">Allow public downloads:</label> > <input type="checkbox" id="public" name="public"> >- Allow public downloads > </input> > [% END %] > </li> >@@ -133,6 +132,16 @@ > [% END %] > [% END %] > >+[% BLOCK back %] >+ [% IF !plugin %] >+ <form id="back"> >+ <fieldset class="action"> >+ <button class="submit">Back</button> >+ </fieldset> >+ </form> >+ [% END %] >+[% END %] >+ > [% BLOCK newsearch %] > <form id="newsearch"> > <fieldset class="action"> >@@ -163,7 +172,7 @@ > <td>[% record.name %]</td> > <td>[% record.filesize %]</td> > <td>[% record.hashvalue %]</td> >- <td>[% record.categorycode %]</td> >+ <td>[% record.uploadcategorycode %]</td> > [% IF !plugin %] > <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> > <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td> >@@ -173,7 +182,7 @@ > <a href="" onclick="Choose('[% record.hashvalue %]'); return false;">Choose</a> > [% END %] > <a href="" onclick="SubmitMe( 'download', [% record.id %] ); return false;">Download</a> >- <a href="" onclick="ClearField(); SubmitMe( 'delete', [% record.id %] ); return false;">Delete</a> >+ <a href="" onclick="DeleteEntry( [% record.id %] ); return false;">Delete</a> > </td> > </tr> > [% 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(); >+ }); > }); > //]]> > </script> >@@ -329,6 +347,7 @@ $(document).ready(function() { > <h3>Your request gave the following results:</h3> > [% PROCESS table_results %] > [% PROCESS closer %] >+ [% PROCESS back %] > [% ELSE %] > <h4>Sorry, your request had no results.</h4> > [% PROCESS newsearch %] >diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t >index d818034..c73675d 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 >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14321
:
41498
|
41499
|
41500
|
41501
|
41555
|
41556
|
41557
|
41558
|
41559
|
41560
|
41561
|
41562
|
41665
|
41666
|
41667
|
41668
|
41669
|
41677
|
41873
|
41874
|
41875
|
41876
|
41877
|
41878
|
41879
|
41880
|
41881
|
42411
|
42412
|
42413
|
42414
|
42558
|
42559
|
42560
|
42561
|
42584
|
42587
|
42588
|
42589
|
42590
|
42591
|
42660
|
42661
|
42662
|
42663
|
42664
|
42665
|
42666
|
42707
|
42726
|
42727
|
42728
|
42729
|
42730
|
42731
|
42732
|
42889
|
42890