[Bug 43807] New: BorrowerMandatoryField is not being respected in the API
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 Bug ID: 43807 Summary: BorrowerMandatoryField is not being respected in the API Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: matt.blenkinsop@openfifth.co.uk QA Contact: tomascohen@gmail.com CC: tomascohen@gmail.com Target Milestone: --- When creating a patron via the API, the BorrowerMandatoryField syspref is not being respected -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |matt.blenkinsop@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 --- Comment #1 from Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> --- Created attachment 207981 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207981&action=edit Bug 43807: Enforce BorrowerMandatoryField in the Koha::Patron->store method This commit adds an exception for a missing mandatory field and enforces it using a check_mandatory_fields option passed to the store method. In future this could be enforced without the option but there are a large number of instances, especially in unit tests that would need updating. Test plan: 1) Set a selection of fields in BorrowerMandatoryField 2) Create a Patron via the API - it should succeed even with some of those fields blank 3) Apply patches and restart_all 4) Re-try the request - an exception should be thrown Assisted-by: Sonnet 5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 Frédéric Demians <f.demians@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |f.demians@tamil.fr Status|Needs Signoff |Failed QA --- Comment #2 from Frédéric Demians <f.demians@tamil.fr> --- This patch introduces a regression in WUI when adding a patron type I. To reproduce, BorrowerMandatoryField=surname|firstname|cardnumber Without the patch, add a new patron, category School. There is no surname field, and it's not a problem. With the patch, do the same. When clicking Save, the patron is not created: "The following mandatory fields are empty: firstname" check_mandatory_fields should check the syspref but also the patron category to skip unused fields by the category's type. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 --- Comment #3 from Frédéric Demians <f.demians@tamil.fr> --- There is no surname => There is no firstname -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 --- Comment #4 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 208309 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208309&action=edit Bug 43807: Add regression tests This patch adds tests for check_mandatory_fields() covering fields the patron entry form does not render: person-only fields for organisation (type I) categories, and fields listed in BorrowerUnwantedField. Those can never be filled from the staff interface, so enforcing them makes it impossible to save the patron (see comment 2). The tests are expected to fail with the current patch. A follow-up is needed in check_mandatory_fields() to make them pass, while keeping the fields the form does render (surname for organisations, firstname for persons) mandatory. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Patron.t => FAIL: Tests fail! Organisation patrons and unwanted fields are rejected 3. Apply the follow-up fixing check_mandatory_fields() 4. Repeat step 2 => SUCCESS: Tests pass! 5. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 Frédéric Demians <f.demians@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 Frédéric Demians <f.demians@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207981|0 |1 is obsolete| | Attachment #208309|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 --- Comment #5 from Frédéric Demians <f.demians@tamil.fr> --- Created attachment 208341 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208341&action=edit Bug 43807: Enforce BorrowerMandatoryField in the Koha::Patron->store method This commit adds an exception for a missing mandatory field and enforces it using a check_mandatory_fields option passed to the store method. In future this could be enforced without the option but there are a large number of instances, especially in unit tests that would need updating. Test plan: 1) Set a selection of fields in BorrowerMandatoryField 2) Create a Patron via the API - it should succeed even with some of those fields blank 3) Apply patches and restart_all 4) Re-try the request - an exception should be thrown Assisted-by: Sonnet 5 (Anthropic) Signed-off-by: Frédéric Demians <f.demians@tamil.fr> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 --- Comment #6 from Frédéric Demians <f.demians@tamil.fr> --- Created attachment 208342 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208342&action=edit Bug 43807: Add regression tests This patch adds tests for check_mandatory_fields() covering fields the patron entry form does not render: person-only fields for organisation (type I) categories, and fields listed in BorrowerUnwantedField. Those can never be filled from the staff interface, so enforcing them makes it impossible to save the patron (see comment 2). The tests are expected to fail with the current patch. A follow-up is needed in check_mandatory_fields() to make them pass, while keeping the fields the form does render (surname for organisations, firstname for persons) mandatory. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Patron.t => FAIL: Tests fail! Organisation patrons and unwanted fields are rejected 3. Apply the follow-up fixing check_mandatory_fields() 4. Repeat step 2 => SUCCESS: Tests pass! 5. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Frédéric Demians <f.demians@tamil.fr> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43807 --- Comment #7 from Frédéric Demians <f.demians@tamil.fr> --- Created attachment 208343 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208343&action=edit Bug 43807: (follow-up) Don't enforce fields the patron form doesn't render check_mandatory_fields() rejected patrons whose mandatory fields are not rendered by the patron entry form, and so can never be filled from the staff interface: - for organisation (type I) categories, the fields that only apply to persons: title, firstname, preferred_name, middle_name, dateofbirth, initials and pronouns; - the fields listed in BorrowerUnwantedField. With firstname in BorrowerMandatoryField, an organisation patron could not be created anymore. This patch skips these fields. The fields rendered for organisations (surname) and for persons (firstname...) remain mandatory. It fixes the added unit tests. It also fixes the tests of the first patch, which built a random category: firstname isn't mandatory for organisations. Test plan: 1. Apply the first two patches only (the tests). 2. prove t/db_dependent/Koha/Patron.t => FAIL: check_mandatory_fields() tests 3. Set BorrowerMandatoryField to surname|firstname|cardnumber. 4. Patrons > New patron > School (a type I category): fill the name and the card number, save. => The patron is not created: "The following mandatory fields are empty: firstname". 5. Apply this patch, restart_all. 6. Repeat step 2: the tests pass. 7. Repeat step 4: the patron is created. 8. Patrons > New patron > Patron (a type A category): leave the first name empty and check that it is still required. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org