From 2a79e3a00cd3b0bd256ffa5b4bb9cd7c3c1c38c9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 10 Nov 2022 14:39:35 -0300 Subject: [PATCH] Bug 24606: (QA follow-up) borrowernumber => patron_id Signed-off-by: Tomas Cohen Arazi --- Koha/Item/Templates.pm | 10 ++++---- cataloguing/additem.pl | 12 +++++----- .../data/mysql/atomicupdate/bug_24606.pl | 4 ++-- installer/data/mysql/kohastructure.sql | 4 ++-- t/db_dependent/Koha/Item/Templates.t | 24 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Koha/Item/Templates.pm b/Koha/Item/Templates.pm index 9c635f9bd1..b41e6f1b41 100644 --- a/Koha/Item/Templates.pm +++ b/Koha/Item/Templates.pm @@ -38,24 +38,24 @@ representing templates owned by the user or shared to the user respectivetly. =cut sub get_available { - my ( $class, $borrowernumber ) = @_; + my ( $class, $patron_id ) = @_; my $params = { order_by => 'name', - columns => [ 'id', 'borrowernumber', 'name', 'is_shared' ], + columns => [ 'id', 'patron_id', 'name', 'is_shared' ], }; return { owned => Koha::Item::Templates->search( { - borrowernumber => $borrowernumber + patron_id => $patron_id }, $params ), shared => Koha::Item::Templates->search( { - borrowernumber => { "!=" => $borrowernumber }, - is_shared => 1 + patron_id => { "!=" => $patron_id }, + is_shared => 1 }, $params ), diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 60ca31efd5..d4fca012a1 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -186,7 +186,7 @@ my $use_template_for_session = $input->param('use_template_for_session') || $inp my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId'); if ( $delete_template_submit ) { my $t = Koha::Item::Templates->find($template_id); - $t->delete if $t && ( $t->borrowernumber eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) ); + $t->delete if $t && ( $t->patron_id eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) ); $template_id = undef; $use_template_for_session = undef; } @@ -283,7 +283,7 @@ if ($op eq "additem") { contents => $item->unblessed, } ) if $template && ( - $template->borrowernumber eq $loggedinuser + $template->patron_id eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) ); @@ -291,10 +291,10 @@ if ($op eq "additem") { else { my $template = Koha::Item::Template->new( { - name => $template_name, - borrowernumber => $loggedinuser, - is_shared => $template_is_shared ? 1 : 0, - contents => $item->unblessed, + name => $template_name, + patron_id => $loggedinuser, + is_shared => $template_is_shared ? 1 : 0, + contents => $item->unblessed, } )->store(); } diff --git a/installer/data/mysql/atomicupdate/bug_24606.pl b/installer/data/mysql/atomicupdate/bug_24606.pl index 18b0eba217..5401cdc697 100755 --- a/installer/data/mysql/atomicupdate/bug_24606.pl +++ b/installer/data/mysql/atomicupdate/bug_24606.pl @@ -11,12 +11,12 @@ return { $dbh->do(q{ CREATE TABLE `item_editor_templates` ( `id` INT(11) NOT NULL auto_increment COMMENT "id for the template", - `borrowernumber` int(11) DEFAULT NULL COMMENT "creator of this template", + `patron_id` int(11) DEFAULT NULL COMMENT "creator of this template", `name` MEDIUMTEXT NOT NULL COMMENT "template name", `is_shared` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "controls if template is shared", `contents` LONGTEXT NOT NULL COMMENT "json encoded template data", PRIMARY KEY (`id`), - CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `bn` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; }); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 216e2e2408..7015a95ff3 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1972,12 +1972,12 @@ CREATE TABLE `item_group_items` ( DROP TABLE IF EXISTS `item_editor_templates`; CREATE TABLE `item_editor_templates` ( `id` INT(11) NOT NULL auto_increment COMMENT "id for the template", - `borrowernumber` int(11) DEFAULT NULL COMMENT "creator of this template", + `patron_id` int(11) DEFAULT NULL COMMENT "creator of this template", `name` MEDIUMTEXT NOT NULL COMMENT "template name", `is_shared` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "controls if template is shared", `contents` LONGTEXT NOT NULL COMMENT "json encoded template data", PRIMARY KEY (`id`), - CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `bn` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- diff --git a/t/db_dependent/Koha/Item/Templates.t b/t/db_dependent/Koha/Item/Templates.t index 5e8956395b..1a7bc25556 100755 --- a/t/db_dependent/Koha/Item/Templates.t +++ b/t/db_dependent/Koha/Item/Templates.t @@ -58,28 +58,28 @@ subtest 'get_available' => sub { my $owner_template = Koha::Item::Template->new( { - borrowernumber => $patron_1->id, - name => 'My template', - contents => { location => 'test' }, - is_shared => 0, + patron_id => $patron_1->id, + name => 'My template', + contents => { location => 'test' }, + is_shared => 0, } )->store(); my $shared_template = Koha::Item::Template->new( { - borrowernumber => $patron_2->id, - name => 'My template', - contents => { location => 'test' }, - is_shared => 1, + patron_id => $patron_2->id, + name => 'My template', + contents => { location => 'test' }, + is_shared => 1, } )->store(); my $unshared_template = Koha::Item::Template->new( { - borrowernumber => $patron_2->id, - name => 'My template', - contents => { location => 'test' }, - is_shared => 0, + patron_id => $patron_2->id, + name => 'My template', + contents => { location => 'test' }, + is_shared => 0, } )->store(); -- 2.39.5