Bug 35635

Summary: Expand patron attribute type mandatory field to allow different settings for OPAC and staff interface
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: PatronsAssignee: Lucas Gass (lukeg) <lucas>
Status: Pushed to main --- QA Contact: Jonathan Druart <jonathan.druart>
Severity: enhancement    
Priority: P5 - low CC: blawlor, gmcharlt, hebah, jonathan.druart, kyle.m.hall, nick, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement expands the patron attribute type "Mandatory" field, allowing for different configurations for the OPAC and the staff interface.
Version(s) released in:
25.05.00
Circulation function:
Attachments: Bug 35635: DB Updates
Bug 35635: DO NOT PUSH - Schema updates
Bug 35635: Split mandatory field into mandatory and opac_mandatory
Bug 35635: Add opac_mandatory to patron attribute table
Bug 35635: Add opac_mandatory to patron attribute table
Bug 35635: DB Updates
Bug 35635: DO NOT PUSH - Schema updates
Bug 35635: Split mandatory field into mandatory and opac_mandatory
Bug 35635: Add opac_mandatory to patron attribute table
Bug 35635: (QA follow-up): fix terminology
Bug 35635: (follow-up) Fix DBRev
Bug 35635: (QA follow-up): fix terminology
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC
Bug 35635: DB Updates
Bug 35635: DO NOT PUSH - Schema updates
Bug 35635: Split mandatory field into mandatory and opac_mandatory
Bug 35635: Add opac_mandatory to patron attribute table
Bug 35635: (follow-up) Fix DBRev
Bug 35635: (QA follow-up): fix terminology
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC
Bug 35635: Flag opac_mandatory as boolean
Bug 35635: Fix server-side check
Bug 35635: Adjust atomic update
Bug 35635: DB Updates
Bug 35635: DO NOT PUSH - Schema updates
Bug 35635: Split mandatory field into mandatory and opac_mandatory
Bug 35635: Add opac_mandatory to patron attribute table
Bug 35635: (follow-up) Fix DBRev
Bug 35635: (QA follow-up): fix terminology
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC
Bug 35635: Flag opac_mandatory as boolean
Bug 35635: Fix server-side check
Bug 35635: Adjust atomic update
Bug 35635: DB Updates
Bug 35635: Split mandatory field into mandatory and opac_mandatory
Bug 35635: Add opac_mandatory to patron attribute table
Bug 35635: (follow-up) Fix DBRev
Bug 35635: (QA follow-up): fix terminology
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC
Bug 35635: Flag opac_mandatory as boolean
Bug 35635: Fix server-side check
Bug 35635: Adjust atomic update
Bug 35635: DO NOT PUSH - Schema updates
Bug 35635: Add missing NOT NULL clause in db rev

Description Lucas Gass (lukeg) 2023-12-21 21:20:44 UTC
Within Patron attribute types there is a checkbox to make the attribute mandatory. 

Some libraries need to be able to make patron attribute types mandatory on the OPAC but not the staff interface, or vise versa.
Comment 1 Lucas Gass (lukeg) 2024-06-05 22:17:05 UTC
Created attachment 167500 [details] [review]
Bug 35635: DB Updates
Comment 2 Lucas Gass (lukeg) 2024-06-05 22:17:07 UTC
Created attachment 167501 [details] [review]
Bug 35635: DO NOT PUSH - Schema updates
Comment 3 Lucas Gass (lukeg) 2024-06-05 22:17:10 UTC
Created attachment 167502 [details] [review]
Bug 35635: Split mandatory field into mandatory and opac_mandatory
Comment 4 Lucas Gass (lukeg) 2024-06-06 13:27:18 UTC
Created attachment 167546 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table
Comment 5 Lucas Gass (lukeg) 2024-06-06 13:37:15 UTC
Created attachment 167548 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table

To test:
1. Before applying the patch go to Adminstration > Patron attribute types
2. Create or modify some attributes to be mandatory and some to not be mandatory.
3. APPLY PATCH, updatedatabase, restart_all
4. Go back to Adminstration > Patron attribute types. The patron attributes that were made mandatory should now also have the opac_mandatory field checked.
5. Make sure that you can change the correctly save the new "OPAC mandatory:" field.
6. If the 'Display in OPAC:' field is unchecked the 'OPAC mandatory:' checkbox should be disabled.
7. Mark some patron attributes as 'OPAC mandatory:'.
8. Go to the OPAC self reg page, the field should be required.
9. BAck on Adminstration > Patron attribute types check some attributes as 'OPAC mandatory:' and 'Editable in OPAC:'.
10. As a logged in OPAC user go to "Personal details" and make sure the attribute is required.
11. For the same attriubute as step 9-10 , mark as NOT 'Editable in OPAC:'. Make sure you can still save the form on the OPAC "Personal details" page.
Comment 6 Brendan Lawlor 2024-06-11 19:45:10 UTC
Created attachment 167643 [details] [review]
Bug 35635: DB Updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 7 Brendan Lawlor 2024-06-11 19:45:12 UTC
Created attachment 167644 [details] [review]
Bug 35635: DO NOT PUSH - Schema updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 8 Brendan Lawlor 2024-06-11 19:45:14 UTC
Created attachment 167645 [details] [review]
Bug 35635: Split mandatory field into mandatory and opac_mandatory

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 9 Brendan Lawlor 2024-06-11 19:45:16 UTC
Created attachment 167646 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table

To test:
1. Before applying the patch go to Adminstration > Patron attribute types
2. Create or modify some attributes to be mandatory and some to not be mandatory.
3. APPLY PATCH, updatedatabase, restart_all
4. Go back to Adminstration > Patron attribute types. The patron attributes that were made mandatory should now also have the opac_mandatory field checked.
5. Make sure that you can change the correctly save the new "OPAC mandatory:" field.
6. If the 'Display in OPAC:' field is unchecked the 'OPAC mandatory:' checkbox should be disabled.
7. Mark some patron attributes as 'OPAC mandatory:'.
8. Go to the OPAC self reg page, the field should be required.
9. BAck on Adminstration > Patron attribute types check some attributes as 'OPAC mandatory:' and 'Editable in OPAC:'.
10. As a logged in OPAC user go to "Personal details" and make sure the attribute is required.
11. For the same attriubute as step 9-10 , mark as NOT 'Editable in OPAC:'. Make sure you can still save the form on the OPAC "Personal details" page.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 10 Brendan Lawlor 2024-06-11 19:49:24 UTC
Testing notes:
Everything worked according to the test plan, but one small clarification for steps #7 and 8 is that for the attributes to be on the self reg page I also had to  check 'Editable in OPAC' for the attribute to appear on the self reg page.
Comment 11 Victor Grousset/tuxayo 2024-11-24 17:30:56 UTC
Created attachment 174962 [details] [review]
Bug 35635: (QA follow-up): fix terminology
Comment 12 Victor Grousset/tuxayo 2024-11-24 17:31:34 UTC
Comment on attachment 167646 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table

Review of attachment 167646 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt
@@ +333,3 @@
>                <th>Library limitation</th>
>                <th>Authorized value category</th>
>                <th>Mandatory</th>

Looks like this should be changed to say it's about the staff interface.
Comment 13 Victor Grousset/tuxayo 2024-11-24 17:36:10 UTC
db rev isn't updating the COMMENT for the "mandatory" column when in the kohastructure, it is changed.
That comment ends up in Koha/Schema/Result so depending if the RM and RMaint runs dbic after a doing a databaseupdate or starting KTD they will end up with different POD in the schema files and a different checksum. Which will raise a warning latter for them or someone else.
So even COMMENTs need to be in sync between a clean install and an upgraded install.

About clean install vs upgraded install the column opac_mandatory has a divergence on it's COMMENT too: "on the OPAC" vs "in the OPAC"
And "NOT NULL" is only present on of the two scenarios.
Comment 14 Victor Grousset/tuxayo 2024-11-24 22:34:03 UTC
> and a different checksum. Which will raise a warning latter for them or someone else.


The checksum check won't trip actually. It's ok in this scenario. There will still be unexpected schema class changes when running dbic later.
Comment 15 Lucas Gass (lukeg) 2024-12-02 18:13:51 UTC
Created attachment 175059 [details] [review]
Bug 35635: (follow-up) Fix DBRev
Comment 16 Victor Grousset/tuxayo 2024-12-17 20:42:53 UTC
Created attachment 175635 [details] [review]
Bug 35635: (QA follow-up): fix terminology
Comment 17 Victor Grousset/tuxayo 2024-12-17 23:08:35 UTC
Thanks for the follow-up.

Sorry there is still this remaining:

> And "NOT NULL" is only present on one of the two scenarios.


And comment 12 but it was confusing:
<th>Mandatory - OPAC</th> was added.
But just above there is <th>Mandatory</th>
Which looks like it should be changed to say it's about the staff interface. To avoid confusion which in the worst case could raise doubts about "Mandatory" being about both staff interface and OPAC.
Comment 18 Victor Grousset/tuxayo 2024-12-17 23:09:08 UTC
Follow-up updated for another terminology issue.
Comment 19 Lucas Gass (lukeg) 2024-12-20 21:46:11 UTC
Created attachment 175858 [details] [review]
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC
Comment 20 Jonathan Druart 2025-01-16 09:40:06 UTC
1. You need that in Koha/Schema/Result/BorrowerAttributeType.pm
     '+mandatory'                 => { is_boolean => 1 },
+    '+opac_mandatory'            => { is_boolean => 1 },

The QA script caught it

2. It does not work at all, if mandatory staff-side but not opac-side, opac-memberentry displays "You have not filled out all required fields. Please fill in all missing fields and resubmit."
Comment 21 Jonathan Druart 2025-01-16 09:43:25 UTC
Created attachment 176595 [details] [review]
Bug 35635: DB Updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 22 Jonathan Druart 2025-01-16 09:43:29 UTC
Created attachment 176596 [details] [review]
Bug 35635: DO NOT PUSH - Schema updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 23 Jonathan Druart 2025-01-16 09:43:32 UTC
Created attachment 176597 [details] [review]
Bug 35635: Split mandatory field into mandatory and opac_mandatory

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 24 Jonathan Druart 2025-01-16 09:43:35 UTC
Created attachment 176598 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table

To test:
1. Before applying the patch go to Adminstration > Patron attribute types
2. Create or modify some attributes to be mandatory and some to not be mandatory.
3. APPLY PATCH, updatedatabase, restart_all
4. Go back to Adminstration > Patron attribute types. The patron attributes that were made mandatory should now also have the opac_mandatory field checked.
5. Make sure that you can change the correctly save the new "OPAC mandatory:" field.
6. If the 'Display in OPAC:' field is unchecked the 'OPAC mandatory:' checkbox should be disabled.
7. Mark some patron attributes as 'OPAC mandatory:'.
8. Go to the OPAC self reg page, the field should be required.
9. BAck on Adminstration > Patron attribute types check some attributes as 'OPAC mandatory:' and 'Editable in OPAC:'.
10. As a logged in OPAC user go to "Personal details" and make sure the attribute is required.
11. For the same attriubute as step 9-10 , mark as NOT 'Editable in OPAC:'. Make sure you can still save the form on the OPAC "Personal details" page.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 25 Jonathan Druart 2025-01-16 09:43:38 UTC
Created attachment 176599 [details] [review]
Bug 35635: (follow-up) Fix DBRev

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 26 Jonathan Druart 2025-01-16 09:43:41 UTC
Created attachment 176600 [details] [review]
Bug 35635: (QA follow-up): fix terminology

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 27 Jonathan Druart 2025-01-16 09:43:44 UTC
Created attachment 176601 [details] [review]
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 28 Jonathan Druart 2025-01-16 09:43:47 UTC
Created attachment 176602 [details] [review]
Bug 35635: Flag opac_mandatory as boolean

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 29 Jonathan Druart 2025-01-16 09:43:50 UTC
Created attachment 176603 [details] [review]
Bug 35635: Fix server-side check

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 30 Jonathan Druart 2025-01-16 09:45:19 UTC
Created attachment 176604 [details] [review]
Bug 35635: Adjust atomic update

So that we don't do anything if the new column exists already.
Comment 31 Lucas Gass (lukeg) 2025-02-11 21:41:01 UTC
Created attachment 177803 [details] [review]
Bug 35635: DB Updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 32 Lucas Gass (lukeg) 2025-02-11 21:41:05 UTC
Created attachment 177804 [details] [review]
Bug 35635: DO NOT PUSH - Schema updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 33 Lucas Gass (lukeg) 2025-02-11 21:41:09 UTC
Created attachment 177805 [details] [review]
Bug 35635: Split mandatory field into mandatory and opac_mandatory

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 34 Lucas Gass (lukeg) 2025-02-11 21:41:12 UTC
Created attachment 177806 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table

To test:
1. Before applying the patch go to Adminstration > Patron attribute types
2. Create or modify some attributes to be mandatory and some to not be mandatory.
3. APPLY PATCH, updatedatabase, restart_all
4. Go back to Adminstration > Patron attribute types. The patron attributes that were made mandatory should now also have the opac_mandatory field checked.
5. Make sure that you can change the correctly save the new "OPAC mandatory:" field.
6. If the 'Display in OPAC:' field is unchecked the 'OPAC mandatory:' checkbox should be disabled.
7. Mark some patron attributes as 'OPAC mandatory:'.
8. Go to the OPAC self reg page, the field should be required.
9. BAck on Adminstration > Patron attribute types check some attributes as 'OPAC mandatory:' and 'Editable in OPAC:'.
10. As a logged in OPAC user go to "Personal details" and make sure the attribute is required.
11. For the same attriubute as step 9-10 , mark as NOT 'Editable in OPAC:'. Make sure you can still save the form on the OPAC "Personal details" page.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 35 Lucas Gass (lukeg) 2025-02-11 21:41:16 UTC
Created attachment 177807 [details] [review]
Bug 35635: (follow-up) Fix DBRev

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 36 Lucas Gass (lukeg) 2025-02-11 21:41:19 UTC
Created attachment 177808 [details] [review]
Bug 35635: (QA follow-up): fix terminology

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 37 Lucas Gass (lukeg) 2025-02-11 21:41:22 UTC
Created attachment 177809 [details] [review]
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 38 Lucas Gass (lukeg) 2025-02-11 21:41:26 UTC
Created attachment 177810 [details] [review]
Bug 35635: Flag opac_mandatory as boolean

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 39 Lucas Gass (lukeg) 2025-02-11 21:41:29 UTC
Created attachment 177811 [details] [review]
Bug 35635: Fix server-side check

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 40 Lucas Gass (lukeg) 2025-02-11 21:41:32 UTC
Created attachment 177812 [details] [review]
Bug 35635: Adjust atomic update

So that we don't do anything if the new column exists already.
Comment 41 Lucas Gass (lukeg) 2025-02-11 23:27:54 UTC
Created attachment 177814 [details] [review]
Bug 35635: DB Updates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 42 Lucas Gass (lukeg) 2025-02-11 23:27:57 UTC
Created attachment 177815 [details] [review]
Bug 35635: Split mandatory field into mandatory and opac_mandatory

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 43 Lucas Gass (lukeg) 2025-02-11 23:28:00 UTC
Created attachment 177816 [details] [review]
Bug 35635: Add opac_mandatory to patron attribute table

To test:
1. Before applying the patch go to Adminstration > Patron attribute types
2. Create or modify some attributes to be mandatory and some to not be mandatory.
3. APPLY PATCH, updatedatabase, restart_all
4. Go back to Adminstration > Patron attribute types. The patron attributes that were made mandatory should now also have the opac_mandatory field checked.
5. Make sure that you can change the correctly save the new "OPAC mandatory:" field.
6. If the 'Display in OPAC:' field is unchecked the 'OPAC mandatory:' checkbox should be disabled.
7. Mark some patron attributes as 'OPAC mandatory:'.
8. Go to the OPAC self reg page, the field should be required.
9. BAck on Adminstration > Patron attribute types check some attributes as 'OPAC mandatory:' and 'Editable in OPAC:'.
10. As a logged in OPAC user go to "Personal details" and make sure the attribute is required.
11. For the same attriubute as step 9-10 , mark as NOT 'Editable in OPAC:'. Make sure you can still save the form on the OPAC "Personal details" page.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 44 Lucas Gass (lukeg) 2025-02-11 23:28:02 UTC
Created attachment 177817 [details] [review]
Bug 35635: (follow-up) Fix DBRev

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 45 Lucas Gass (lukeg) 2025-02-11 23:28:05 UTC
Created attachment 177818 [details] [review]
Bug 35635: (QA follow-up): fix terminology

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 46 Lucas Gass (lukeg) 2025-02-11 23:28:07 UTC
Created attachment 177819 [details] [review]
Bug 35635: (follow-up): Mark madatory field as staff interface/OPAC

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 47 Lucas Gass (lukeg) 2025-02-11 23:28:10 UTC
Created attachment 177820 [details] [review]
Bug 35635: Flag opac_mandatory as boolean

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 48 Lucas Gass (lukeg) 2025-02-11 23:28:13 UTC
Created attachment 177821 [details] [review]
Bug 35635: Fix server-side check

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 49 Lucas Gass (lukeg) 2025-02-11 23:28:15 UTC
Created attachment 177822 [details] [review]
Bug 35635: Adjust atomic update

So that we don't do anything if the new column exists already.
Comment 50 Lucas Gass (lukeg) 2025-02-11 23:28:18 UTC
Created attachment 177823 [details] [review]
Bug 35635: DO NOT PUSH - Schema updates
Comment 51 Katrin Fischer 2025-02-20 16:42:24 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 52 Jonathan Druart 2025-03-11 13:22:56 UTC
Created attachment 179165 [details] [review]
Bug 35635: Add missing NOT NULL clause in db rev

Jenkins job testing the update DB was failing:

18:11:48 koha_1       | +++ b/Koha/Schema/Result/BorrowerAttributeType.pm
18:11:48 koha_1       | @@ -141,7 +141,7 @@ defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0
18:11:48 koha_1       |
18:11:48 koha_1       |    data_type: 'tinyint'
18:11:48 koha_1       |    default_value: 0
18:11:48 koha_1       | -  is_nullable: 0
18:11:48 koha_1       | +  is_nullable: 1
18:11:48 koha_1       |
18:11:48 koha_1       |  defines if the attribute is mandatory or not in the staff interface
18:11:48 koha_1       |
18:11:48 koha_1       | @@ -149,7 +149,7 @@ defines if the attribute is mandatory or not in the staff interface
18:11:48 koha_1       |
18:11:48 koha_1       |    data_type: 'tinyint'
18:11:48 koha_1       |    default_value: 0
18:11:48 koha_1       | -  is_nullable: 0
18:11:48 koha_1       | +  is_nullable: 1
18:11:48 koha_1       |
18:11:48 koha_1       |  defines if the attribute is mandatory or not in the OPAC
18:11:48 koha_1       |
18:11:48 koha_1       | @@ -185,9 +185,9 @@ __PACKAGE__->add_columns(
18:11:48 koha_1       |    "keep_for_pseudonymization",
18:11:48 koha_1       |    { data_type => "tinyint", default_value => 0, is_nullable => 0 },
18:11:48 koha_1       |    "mandatory",
18:11:48 koha_1       | -  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
18:11:48 koha_1       | +  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
18:11:48 koha_1       |    "opac_mandatory",
18:11:48 koha_1       | -  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
18:11:49 koha_1       | +  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
Comment 53 Katrin Fischer 2025-03-11 13:43:14 UTC
Follow-up pushed to main.