Bug 8326: Make repeatable and unique_id modifiable when editing patron attribute...
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 May 2020 13:36:24 +0000 (15:36 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 15 Feb 2021 10:48:55 +0000 (11:48 +0100)
commita066f03b5e89f1a031565c024c05864449153ba6
treebd5232d80887500d50a03ad70df1b8ccee5ddd18
parent35994c1da5f5a7d29a192310822bf41a978d0a1f
Bug 8326: Make repeatable and unique_id modifiable when editing patron attribute type

This patch add the ability to modify the attribute "repeatable" and
"unique_id" for a patron's attribute type.
Prior to this patch it was not possible, to keep data integrity.

When editing an attr type, the controller will check is the value can be
modified, depending on the existing patron's attributes.

Test plan:
0/ Setup
Create 1 patron attribute PA1 that can be repeatable
Create 1 patron attribute PA2 that does not have the unique restriction
Create 1 patron attribute PA3 that cannot be repeatable and does not
have the unique restriction

1/
Edit them and confirm that you can modify the repeatable and unique
restrictions

2/ Restore values from 0.
Create a patron P1 with several PA1, PA2=42 and whatever in PA3

3/ Edit PA1 => you cannot remove the repeatable flag but can still
remove the unique

4/ Create a patron P2 with PA2=42

5/ Edit PA2 => you cannot add the unique flag

Play a bit more with the different combinaisons and confirm that it
works as advertised.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Exceptions/Patron/Attribute/Type.pm [new file with mode: 0644]
Koha/Patron/Attribute/Type.pm
admin/patron-attr-types.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt
t/db_dependent/Koha/Patron/Attribute/Types.t