Bug 24606: (QA follow-up) borrowernumber => patron_id
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 10 Nov 2022 17:39:35 +0000 (14:39 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 10 Nov 2022 17:39:35 +0000 (14:39 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Item/Templates.pm
cataloguing/additem.pl
installer/data/mysql/atomicupdate/bug_24606.pl
installer/data/mysql/kohastructure.sql
t/db_dependent/Koha/Item/Templates.t

index 9c635f9..b41e6f1 100644 (file)
@@ -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
         ),
index 60ca31e..d4fca01 100755 (executable)
@@ -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();
         }
index 18b0eba..5401cdc 100755 (executable)
@@ -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;
             });
 
index 216e2e2..7015a95 100644 (file)
@@ -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;
 
 --
index 5e89563..1a7bc25 100755 (executable)
@@ -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();