Bug 24606: (QA follow-up) borrowernumber => patron_id

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomás Cohen Arazi 2022-11-10 14:39:35 -03:00
parent f31b4c48fc
commit 2a79e3a00c
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
5 changed files with 27 additions and 27 deletions

View 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
),

View file

@ -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();
}

View file

@ -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;
});

View 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;
--

View file

@ -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();