Bugzilla – Attachment 101793 Details for
Bug 22887
authorised_values is missing a unique constraint on category + authorised_value
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22887: Rely on unique constraint in av admin
Bug-22887-Rely-on-unique-constraint-in-av-admin.patch (text/plain), 3.20 KB, created by
Jonathan Druart
on 2020-03-26 09:47:36 UTC
(
hide
)
Description:
Bug 22887: Rely on unique constraint in av admin
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-26 09:47:36 UTC
Size:
3.20 KB
patch
obsolete
>From 4712b4327d7a1f62b1740affae2db865e785c629 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 26 Mar 2020 10:29:11 +0100 >Subject: [PATCH] Bug 22887: Rely on unique constraint in av admin > >Test plan: >Try to create 2 AV with the same code for the same category. >You should see a warning >--- > admin/authorised_values.pl | 31 +++++++------------ > .../en/modules/admin/authorised_values.tt | 2 -- > 2 files changed, 11 insertions(+), 22 deletions(-) > >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index 34540e1e20..945bd62b73 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -104,17 +104,7 @@ if ($op eq 'add_form') { > my $duplicate_entry = 0; > my @branches = grep { $_ ne q{} } $input->multi_param('branches'); > >- my $already_exists = Koha::AuthorisedValues->search( >- { >- category => $new_category, >- authorised_value => $new_authorised_value, >- } >- )->next; >- >- if ( $already_exists and ( not $id or $already_exists->id != $id ) ) { >- push @messages, {type => 'error', code => 'already_exists' }; >- } >- elsif ( $new_category eq 'branches' or $new_category eq 'itemtypes' or $new_category eq 'cn_source' ) { >+ if ( $new_category eq 'branches' or $new_category eq 'itemtypes' or $new_category eq 'cn_source' ) { > push @messages, {type => 'error', code => 'invalid_category_name' }; > } > elsif ( $id ) { # Update >@@ -136,17 +126,18 @@ if ($op eq 'add_form') { > } > } > else { # Insert >- my $av = Koha::AuthorisedValue->new( { >- category => $new_category, >- authorised_value => $new_authorised_value, >- lib => scalar $input->param('lib') || undef, >- lib_opac => scalar $input->param('lib_opac') || undef, >- imageurl => $imageurl, >- } ); >- > eval { >- $av->store; >+ my $av = Koha::AuthorisedValue->new( >+ { >+ category => $new_category, >+ authorised_value => $new_authorised_value, >+ lib => scalar $input->param('lib') || undef, >+ lib_opac => scalar $input->param('lib_opac') || undef, >+ imageurl => $imageurl, >+ } >+ )->store; > $av->replace_library_limits( \@branches ); >+ $av->store; > }; > > if ( $@ ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >index 8f71938964..7f3acbe4dd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >@@ -177,8 +177,6 @@ > Authorized value category added successfully. > [% CASE 'success_on_delete' %] > Authorized value deleted successfully. >- [% CASE 'already_exists' %] >- This authorized value already exists. > [% CASE 'cat_already_exists' %] > This authorized value category already exists. > [% CASE 'invalid_category_name' %] >-- >2.20.1
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 22887
:
89550
|
101790
|
101791
|
101792
|
101793
|
101889
|
101890
|
101891
|
101892
|
102409
|
102410
|
102411
|
102412
|
102511
|
102876
|
102877
|
102878
|
102879
|
102880
|
102898
|
102939
|
102999
|
103000