Currently, Koha doesn't allow to limit a patron attribute type to more than one patron category. Let's say I have a patron attribute type STUDENTID, and I want to limit this attribute to the categories "undergrad students" and "grad students". I have to create two different patron attribute types. To replicate: 1) Go to Administration > Patron attribute types 2) Create a new patron attribute 3) Note that the "Category" field is a dropdown and you can't choose more than one patron category to assign this attribute type to.
The ability to limit a patron extended attribute to more than 1 category at a time would be great.
I had to create a whole duplicate set of attributes for a different patron category. It took me awhile to figure that out and now if feels clunky to have these 'near duplicate' attributes in the system. This functionality is really needed.
Agreed, this would be helpful!
Created attachment 139823 [details] [review] Bug 26573: Limit patron attribute types to more than one patron category Test plan: 1. Create patron attribute types, some with a category limit, some without 2. Apply patch 3. Run installer/data/mysql/updatedatabase.pl 4. Run misc/devel/update_dbix_class_files.pl --koha-conf 5. Restart koha 6. Verify that existing category limits were kept 7. Create a new patron attribute type and select multiple category limits. Verify that they have been saved correctly. 8. Edit this patron attribute type and modify category limits. Verify that the changes have been saved correctly 9. Go to the patron creation form, and verify that patron attributes are shown/hidden accordingly when categorycode is changed. 10. Go to patron batch modification tool, enter a cardnumber (or a borrowernumber) and submit the form to go to the next step. Now select a patron attribute type that has category limits and verify that the message shown to the right is correct
Created attachment 143113 [details] [review] [DO NOT PUSH] DBIX schema update
Created attachment 143114 [details] [review] DBIX schema update https://bugs.koha-community.org/show_bug.cgi?id=26573 Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com>
Created attachment 143115 [details] [review] Bug 26573: Limit patron attribute types to more than one patron category Test plan: 1. Create patron attribute types, some with a category limit, some without 2. Apply patch 3. Run installer/data/mysql/updatedatabase.pl 4. Run misc/devel/update_dbix_class_files.pl --koha-conf 5. Restart koha 6. Verify that existing category limits were kept 7. Create a new patron attribute type and select multiple category limits. Verify that they have been saved correctly. 8. Edit this patron attribute type and modify category limits. Verify that the changes have been saved correctly 9. Go to the patron creation form, and verify that patron attributes are shown/hidden accordingly when categorycode is changed. 10. Go to patron batch modification tool, enter a cardnumber (or a borrowernumber) and submit the form to go to the next step. Now select a patron attribute type that has category limits and verify that the message shown to the right is correct Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com>
Created attachment 143116 [details] [review] DBIX schema update https://bugs.koha-community.org/show_bug.cgi?id=26573 Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com> Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com>
All works! A lot of library colleagues will find this useful.
Something went wrong loading file /kohadevbox/koha/installer/data/mysql/kohastructure.sql ([SQL ERROR]: CREATE TABLE `borrower_attribute_types` ( `code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'unique key used to identify each custom field', `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'description for each custom field', `repeatable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines whether one patron/borrower can have multiple values for this custom field (1 for yes, 0 for no)', `unique_id` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this value needs to be unique (1 for yes, 0 for no)', `opac_display` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is visible to patrons on their account in the OPAC (1 for yes, 0 for no)', `opac_editable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is editable by patrons on their account in the OPAC (1 for yes, 0 for no)', `staff_searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is searchable via the patron search in the staff interface (1 for yes, 0 for no)', `authorised_value_category` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from authorised_values that links this custom field to an authorized value category', `display_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field displays in checkout screens', `class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type', `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)', `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not', PRIMARY KEY (`code`), KEY `auth_val_cat_idx` (`authorised_value_category`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ) at /kohadevbox/koha/C4/Installer.pm line 583.
Created attachment 144470 [details] [review] Bug 26573: Limit patron attribute types to more than one patron category Test plan: 1. Create patron attribute types, some with a category limit, some without 2. Apply patch 3. Run installer/data/mysql/updatedatabase.pl 4. Run misc/devel/update_dbix_class_files.pl --koha-conf 5. Restart koha 6. Verify that existing category limits were kept 7. Create a new patron attribute type and select multiple category limits. Verify that they have been saved correctly. 8. Edit this patron attribute type and modify category limits. Verify that the changes have been saved correctly 9. Go to the patron creation form, and verify that patron attributes are shown/hidden accordingly when categorycode is changed. 10. Go to patron batch modification tool, enter a cardnumber (or a borrowernumber) and submit the form to go to the next step. Now select a patron attribute type that has category limits and verify that the message shown to the right is correct Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com>
Created attachment 144471 [details] [review] Bug 26573: Remove remaining reference to category_code column
Patch rebased on master (with the offending comma removed from kohastructure.sql) + a fix in the latest patch Back to needs signoff
Patch doesn't apply. Bug 26573 - Limit patron attribute types to more than one patron category 143113 - [DO NOT PUSH] DBIX schema update 144470 - Bug 26573: Limit patron attribute types to more than one patron category 144471 - Bug 26573: Remove remaining reference to category_code column Apply? [(y)es, (n)o, (i)nteractive] y Applying: DBIX schema update Using index info to reconstruct a base tree... M Koha/Schema/Result/Category.pm M Koha/Schema/Result/TmpHoldsqueue.pm Falling back to patching base and 3-way merge... Auto-merging Koha/Schema/Result/TmpHoldsqueue.pm CONFLICT (content): Merge conflict in Koha/Schema/Result/TmpHoldsqueue.pm Auto-merging Koha/Schema/Result/Category.pm CONFLICT (content): Merge conflict in Koha/Schema/Result/Category.pm error: Failed to merge in the changes. Patch failed at 0001 DBIX schema update
Comment on attachment 143113 [details] [review] [DO NOT PUSH] DBIX schema update Patches apply correctly without the DBIx schema patch, so I'm removing this one. Do not forget to run update_dbix_class_files.pl when testing.
Patches apply for me, but after running installer/data/mysql/updatedatabase.pl and misc/devel/update_dbix_class_files.pl --koha-conf And after restarting koha I get an error when loading patron-attr-types.pl. The trace is quite long, but begins with: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'me.category_code' in 'field list' at /kohadevbox/koha/Koha/Objects.pm line 394 at /usr/share/perl5/DBIx/Class/Exception.pm line 77
Never mind, I was in the wrong branch. However, patches to not seem to apply to master at the moment.
Marking as "Patch doesn't apply" per Benjamin's comment.
Created attachment 159210 [details] [review] Bug 26573: Limit patron attribute types to more than one patron category Test plan: 1. Create patron attribute types, some with a category limit, some without 2. Apply patch 3. Run installer/data/mysql/updatedatabase.pl 4. Run misc/devel/update_dbix_class_files.pl --koha-conf 5. Restart koha 6. Verify that existing category limits were kept 7. Create a new patron attribute type and select multiple category limits. Verify that they have been saved correctly. 8. Edit this patron attribute type and modify category limits. Verify that the changes have been saved correctly 9. Go to the patron creation form, and verify that patron attributes are shown/hidden accordingly when categorycode is changed. 10. Go to patron batch modification tool, enter a cardnumber (or a borrowernumber) and submit the form to go to the next step. Now select a patron attribute type that has category limits and verify that the message shown to the right is correct Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com>
Created attachment 159211 [details] [review] Bug 26573: Remove remaining reference to category_code column
rebase
I tested this in PTFS Europe's sandbox. Everything works according to the test plan but if I try to actually make batch modification from the step 10 I get this error message: The method Koha::Patron::Attribute::Type->category_code is not covered by tests! Trace begun at /kohadevbox/koha/Koha/Object.pm line 964 Koha::Object::AUTOLOAD('Koha::Patron::Attribute::Type=HASH(0x557cbecdce30)') called at /kohadevbox/koha/tools/modborrowers.pl line 408 eval {...} at /kohadevbox/koha/tools/modborrowers.pl line 2 CGI::Compile::ROOT::kohadevbox_koha_tools_modborrowers_2epl::__ANON__('CGI::Compile=HASH(0x557cbec1b4f8)', '', '/kohadevbox/koha/tools/modborrowers.pl', '/kohadevbox/koha/tools', 'ARRAY(0x557cbf067bc8)') called at /usr/share/perl5/CGI/Compile.pm line 151 CGI::Compile::ROOT::kohadevbox_koha_tools_modborrowers_2epl::modborrowers_2epl at /usr/share/perl5/CGI/Emulate/PSGI.pm line 30 CGI::Emulate::PSGI::__ANON__('HASH(0x557cbf1c69d8)') called at /usr/share/perl5/Plack/App/WrapCGI.pm line 95..... I also tested without the patch and batch modification works without it.
This must also impact REST API routes ? Maybe not since I dont see category in : api/v1/swagger/definitions/patron_extended_attribute.yaml
Created attachment 171048 [details] [review] Bug 26573: Limit patron attribute types to more than one patron category Test plan: 1. Create patron attribute types, some with a category limit, some without 2. Apply patch 3. Run installer/data/mysql/updatedatabase.pl 4. Run misc/devel/update_dbix_class_files.pl --koha-conf 5. Restart koha 6. Verify that existing category limits were kept 7. Create a new patron attribute type and select multiple category limits. Verify that they have been saved correctly. 8. Edit this patron attribute type and modify category limits. Verify that the changes have been saved correctly 9. Go to the patron creation form, and verify that patron attributes are shown/hidden accordingly when categorycode is changed. 10. Go to patron batch modification tool, enter a cardnumber (or a borrowernumber) and submit the form to go to the next step. Now select a patron attribute type that has category limits and verify that the message shown to the right is correct Signed-off-by: Aude Charillon <aude-charillon@ptfs-europe.com>
Rebased + fixed the batch modification