Bug 31005 - Cannot edit patrons in other categories if an extended attribute is mandatory and limited to a category
Summary: Cannot edit patrons in other categories if an extended attribute is mandatory...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: master
Hardware: All All
: P5 - low critical (vote)
Assignee: Nick Clemens
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 27857
Blocks:
  Show dependency treegraph
 
Reported: 2022-06-21 16:41 UTC by Nick Clemens
Modified: 2022-07-14 01:02 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes an error when a mandatory patron attribute limited to a specific patron category was causing a '500 error' when editing a patron not in that category.
Version(s) released in:
22.11.00, 22.05.01, 21.11.10, 21.05.17


Attachments
Bug 31005: Unit test (2.56 KB, patch)
2022-06-23 17:32 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31005: Don't inlcude attributes only required for other categories (1.52 KB, patch)
2022-06-23 17:32 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31005: Unit test (2.61 KB, patch)
2022-06-24 14:24 UTC, David Nind
Details | Diff | Splinter Review
Bug 31005: Don't inlcude attributes only required for other categories (1.57 KB, patch)
2022-06-24 14:24 UTC, David Nind
Details | Diff | Splinter Review
Bug 31005: Unit test (2.67 KB, patch)
2022-06-24 14:30 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 31005: Don't inlcude attributes only required for other categories (1.64 KB, patch)
2022-06-24 14:30 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2022-06-21 16:41:18 UTC
To recreate:
1 - Create a new patron attribute - check boxes to make it mandatory and visible etc.
2 - Limit it to 'Patron' or other category
3 - Edit a patron not in that category
4 - Attempt to save
5 - 500 Error
6 - Missing mandatory extended attribute (type=MAND)
Comment 1 Nick Clemens 2022-06-23 17:32:04 UTC
Created attachment 136454 [details] [review]
Bug 31005: Unit test
Comment 2 Nick Clemens 2022-06-23 17:32:08 UTC
Created attachment 136455 [details] [review]
Bug 31005: Don't inlcude attributes only required for other categories

To test:
 1 - Create a new patron attribute - check boxes to make it mandatory and visible etc.
 2 - Limit it to 'Patron' or other category
 3 - Edit a patron not in that category
 4 - Attempt to save
 5 - 500 Error
 6 - Missing mandatory extended attribute (type=MAND)
 7 - Apply patch
 8 - Attempt aedit again
 9 - It succeeds!
10 - Edit a patron in the category with MAND required
11 - on the edit page, right click teh attribute - click 'delete node'
12 - Submit the form
13 - 500 error, but this time that's good, the attribute check works
Comment 3 David Nind 2022-06-24 14:24:15 UTC
Created attachment 136499 [details] [review]
Bug 31005: Unit test

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2022-06-24 14:24:20 UTC
Created attachment 136500 [details] [review]
Bug 31005: Don't inlcude attributes only required for other categories

To test:
 1 - Create a new patron attribute - check boxes to make it mandatory and visible etc.
 2 - Limit it to 'Patron' or other category
 3 - Edit a patron not in that category
 4 - Attempt to save
 5 - 500 Error
 6 - Missing mandatory extended attribute (type=MAND)
 7 - Apply patch
 8 - Attempt aedit again
 9 - It succeeds!
10 - Edit a patron in the category with MAND required
11 - on the edit page, right click teh attribute - click 'delete node'
12 - Submit the form
13 - 500 error, but this time that's good, the attribute check works

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2022-06-24 14:29:38 UTC
Testing notes (using koha-testing-docker):

1. Tests pass: prove t/db_dependent/Koha/Patron.t

2. For step 11: in Firefox enable the web developer tools, select the input field for the attribute, then right click the HTML for the input field in the inspector window and select delete node,
Comment 6 Martin Renvoize 2022-06-24 14:30:51 UTC
Created attachment 136501 [details] [review]
Bug 31005: Unit test

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize 2022-06-24 14:30:55 UTC
Created attachment 136502 [details] [review]
Bug 31005: Don't inlcude attributes only required for other categories

To test:
 1 - Create a new patron attribute - check boxes to make it mandatory and visible etc.
 2 - Limit it to 'Patron' or other category
 3 - Edit a patron not in that category
 4 - Attempt to save
 5 - 500 Error
 6 - Missing mandatory extended attribute (type=MAND)
 7 - Apply patch
 8 - Attempt aedit again
 9 - It succeeds!
10 - Edit a patron in the category with MAND required
11 - on the edit page, right click teh attribute - click 'delete node'
12 - Submit the form
13 - 500 error, but this time that's good, the attribute check works

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize 2022-06-24 14:31:36 UTC
Good catch, simple fix.

Unit tests included and passing

Passing QA
Comment 9 Tomás Cohen Arazi 2022-06-24 14:38:06 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 10 Lucas Gass 2022-06-24 15:48:38 UTC
Backported to 22.05.x for 22.05.01
Comment 11 Arthur Suzuki 2022-06-29 09:09:04 UTC
backported to 21.11.x for 21.11.10,
thx!
Comment 12 Victor Grousset/tuxayo 2022-07-14 01:02:18 UTC
Backported: Pushed to 21.05.x branch for 21.05.17
Nothing to document, marking resolved.