[Bug 42529] New: Move GetAgeRestriction to Koha namespace
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Bug ID: 42529 Summary: Move GetAgeRestriction to Koha namespace Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org `C4::Circulation::GetAgeRestriction` parses age restriction strings (e.g. "FSK 16", "PEGI 6") from biblio metadata using the AgeRestrictionMarker system preference. It is used in 3 places (C4::Circulation twice, C4::Reserves once). I propose: * Add Koha::Biblio->age_restriction method that parses the restriction string and returns the numeric age (or undef if none) * Add Koha::Patron->meets_age_restriction($biblio) that returns whether the patron meets the age restriction * Replace all GetAgeRestriction callers with the new methods * Remove GetAgeRestriction from C4::Circulation * Move the existing test (t/Circulation/AgeRestrictionMarkers.t) to cover the new methods -- 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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Status|NEW |Needs Signoff Patch complexity|--- |Small patch -- 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=42529 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198633 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198633&action=edit Bug 42529: Move GetAgeRestriction to Koha namespace Adds Koha::Biblio->age_restriction that parses the agerestriction value from biblioitems using the AgeRestrictionMarker system preference and returns the numeric age, or undef if none applies. Adds Koha::Patron->meets_age_restriction($biblio) that returns whether the patron meets the age restriction for the given biblio. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198634 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198634&action=edit Bug 42529: Use Koha::Biblio->age_restriction and Koha::Patron->meets_age_restriction Replaces all calls to C4::Circulation::GetAgeRestriction with the new Koha::Patron->meets_age_restriction($biblio) method. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198635 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198635&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation Removes the now-unused GetAgeRestriction function and its dedicated test file (coverage moved to t/db_dependent/Koha/Biblio.t). Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com Blocks| |17677, 42386 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17677 [Bug 17677] [Omnibus] Move C4::Circulation code to the Koha namespace https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42386 [Bug 42386] Unify hold availability checks into Koha::Availability pattern -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198633|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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198634|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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198635|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=42529 --- Comment #4 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198657 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198657&action=edit Bug 42529: Move GetAgeRestriction to Koha namespace Adds Koha::Biblio->age_restriction that parses the agerestriction value from biblioitems using the AgeRestrictionMarker system preference and returns the numeric age, or undef if none applies. Adds Koha::Patron->meets_age_restriction($biblio) that returns whether the patron meets the age restriction for the given biblio. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #5 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198658 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198658&action=edit Bug 42529: Use Koha::Biblio->age_restriction and Koha::Patron->meets_age_restriction Replaces all calls to C4::Circulation::GetAgeRestriction with the new Koha::Patron->meets_age_restriction($biblio) method. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #6 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198659 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198659&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation Removes the now-unused GetAgeRestriction function and its dedicated test file (coverage moved to t/db_dependent/Koha/Biblio.t). Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198657|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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198658|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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198659|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=42529 --- Comment #7 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198660 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198660&action=edit Bug 42529: Move GetAgeRestriction to Koha namespace Adds Koha::Biblio->age_restriction that parses the agerestriction value from biblioitems using the AgeRestrictionMarker system preference and returns the numeric age, or undef if none applies. Adds Koha::Patron->meets_age_restriction($biblio) that returns whether the patron meets the age restriction for the given biblio. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #8 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198661 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198661&action=edit Bug 42529: Use Koha::Biblio->age_restriction and Koha::Patron->meets_age_restriction Replaces all calls to C4::Circulation::GetAgeRestriction with the new Koha::Patron->meets_age_restriction($biblio) method. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #9 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198662 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198662&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation Removes the now-unused GetAgeRestriction function and its dedicated test file (coverage moved to t/db_dependent/Koha/Biblio.t). Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #10 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- After the initial submission I decided to keep the current behavior more strictly, and make `meets_age_restriction` return `undef` when there's no date of birth. This is semantically better, and the tradeoff (handling) is negligible. Some minor QA issues fixed as well. Only false positive spelling issues remain on this patchset. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@gmail.com, | |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Alex Carver [Acerock7] <alex@rcls.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alex@rcls.org Status|Needs Signoff |Failed QA --- Comment #11 from Alex Carver [Acerock7] <alex@rcls.org> --- Hi Tomás-- I get the following error when attempting to prove: t/db_dependent/Koha/Biblio.t .. 40/43 # Looks like you planned 43 tests but ran 44. t/db_dependent/Koha/Biblio.t .. Dubious, test returned 255 (wstat 65280, 0xff00) All 43 subtests passed Test Summary Report ------------------- t/db_dependent/Koha/Biblio.t (Wstat: 65280 (exited 255) Tests: 44 Failed: 1) Failed test: 44 Non-zero exit status: 255 Parse errors: Bad plan. You planned 43 tests but ran 44. Files=1, Tests=44, 29 wallclock secs ( 0.07 usr 0.00 sys + 21.40 cusr 4.92 csys = 26.39 CPU) Result: FAIL -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> 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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198660|0 |1 is obsolete| | Attachment #198661|0 |1 is obsolete| | Attachment #198662|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=42529 --- Comment #12 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 200390 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200390&action=edit Bug 42529: Move GetAgeRestriction to Koha namespace Adds Koha::Biblio->age_restriction that parses the agerestriction value from biblioitems using the AgeRestrictionMarker system preference and returns the numeric age, or undef if none applies. Adds Koha::Patron->meets_age_restriction($biblio) that returns whether the patron meets the age restriction for the given biblio. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #13 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 200391 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200391&action=edit Bug 42529: Use Koha::Biblio->age_restriction and Koha::Patron->meets_age_restriction Replaces all calls to C4::Circulation::GetAgeRestriction with the new Koha::Patron->meets_age_restriction($biblio) method. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #14 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 200392 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200392&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation Removes the now-unused GetAgeRestriction function and its dedicated test file (coverage moved to t/db_dependent/Koha/Biblio.t). Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #15 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Hi, Alex! (In reply to Alex Carver [Acerock7] from comment #11)
Hi Tomás--
I get the following error when attempting to prove:
Yeah! Someone added more tests to the file in `main` so there was a count mismatch. I fixed it now! Test it before it happens again :-P Thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Alex Carver [Acerock7] <alex@rcls.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Alex Carver [Acerock7] <alex@rcls.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200390|0 |1 is obsolete| | Attachment #200391|0 |1 is obsolete| | Attachment #200392|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=42529 --- Comment #16 from Alex Carver [Acerock7] <alex@rcls.org> --- Created attachment 200565 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200565&action=edit Bug 42529: Move GetAgeRestriction to Koha namespace Adds Koha::Biblio->age_restriction that parses the agerestriction value from biblioitems using the AgeRestrictionMarker system preference and returns the numeric age, or undef if none applies. Adds Koha::Patron->meets_age_restriction($biblio) that returns whether the patron meets the age restriction for the given biblio. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Alex Carver [Acerock7] <alex@rcls.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #17 from Alex Carver [Acerock7] <alex@rcls.org> --- Created attachment 200566 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200566&action=edit Bug 42529: Use Koha::Biblio->age_restriction and Koha::Patron->meets_age_restriction Replaces all calls to C4::Circulation::GetAgeRestriction with the new Koha::Patron->meets_age_restriction($biblio) method. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Alex Carver [Acerock7] <alex@rcls.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #18 from Alex Carver [Acerock7] <alex@rcls.org> --- Created attachment 200567 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200567&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation Removes the now-unused GetAgeRestriction function and its dedicated test file (coverage moved to t/db_dependent/Koha/Biblio.t). Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Alex Carver [Acerock7] <alex@rcls.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #19 from Jonathan Druart <jonathan.druart@gmail.com> --- IMO this is yet another candidate for the Koha::Policy namespace. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #20 from Jonathan Druart <jonathan.druart@gmail.com> --- I think the single return (with the `last` statements) that existed in GetAgeRestriction is better than the 2 returns lost in the 2 nested for. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200567|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=42529 --- Comment #21 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 200682 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200682&action=edit Bug 42529: Add Koha::Policy::Biblio::AgeRestriction This patch adds age restriction handling to the Koha namespace: - Koha::Biblio->age_restriction: metadata extractor that parses the agerestriction field using the AgeRestrictionMarker system preference. Returns the numeric age or undef. Uses single return with last pattern. - Koha::Policy::Biblio::AgeRestriction->check($biblio, $patron): policy class that evaluates whether a patron meets the age restriction. Returns a Koha::Result::Boolean (with payload on restriction). Test plan: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #22 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 200683 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200683&action=edit Bug 42529: Use Koha::Policy::Biblio::AgeRestriction for issuing and holds This patch updates CanBookBeIssued and CanItemBeReserved to use the new policy class instead of calling GetAgeRestriction directly. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t => SUCCESS: Tests pass! 2. Apply this patch 3. Repeat step 1 => SUCCESS: Tests pass! 4. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #23 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 200684 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200684&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation GetAgeRestriction is no longer used by any caller. This patch removes it from the exports list and deletes the old test file. The function body is kept for now as it is not harmful and could be used by third-party code. It is no longer exported. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/Circulation/AgeRestrictionMarkers.t => SUCCESS: Tests pass! 2. Apply this patch 3. Run: k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 4. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200565|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=42529 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200566|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=42529 --- Comment #24 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- (In reply to Jonathan Druart from comment #19)
IMO this is yet another candidate for the Koha::Policy namespace.
100%. Done! (In reply to Jonathan Druart from comment #20)
I think the single return (with the `last` statements) that existed in GetAgeRestriction is better than the 2 returns lost in the 2 nested for.
I agree it is more readable, sort of. I implemented it like this now. Setting back to NSO as I rewrote it all. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off Patch complexity|Small patch |Medium patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200682|0 |1 is obsolete| | Attachment #200683|0 |1 is obsolete| | Attachment #200684|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=42529 --- Comment #25 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200710 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200710&action=edit Bug 42529: Add Koha::Policy::Biblio::AgeRestriction This patch adds age restriction handling to the Koha namespace: - Koha::Biblio->age_restriction: metadata extractor that parses the agerestriction field using the AgeRestrictionMarker system preference. Returns the numeric age or undef. Uses single return with last pattern. - Koha::Policy::Biblio::AgeRestriction->check($biblio, $patron): policy class that evaluates whether a patron meets the age restriction. Returns a Koha::Result::Boolean (with payload on restriction). Test plan: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #26 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200711 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200711&action=edit Bug 42529: Use Koha::Policy::Biblio::AgeRestriction for issuing and holds This patch updates CanBookBeIssued and CanItemBeReserved to use the new policy class instead of calling GetAgeRestriction directly. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t => SUCCESS: Tests pass! 2. Apply this patch 3. Repeat step 1 => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #27 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 200712 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200712&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation GetAgeRestriction is no longer used by any caller. This patch removes it from the exports list and deletes the old test file. The function body is kept for now as it is not harmful and could be used by third-party code. It is no longer exported. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/Circulation/AgeRestrictionMarkers.t => SUCCESS: Tests pass! 2. Apply this patch 3. Run: k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #28 from Jonathan Druart <jonathan.druart@gmail.com> ---
Created attachment 200712 [details] [review] The function body is kept for now as it is not harmful and could be used by third-party code. It is no longer exported.
What is this talking about? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA QA Contact|testopia@bugs.koha-communit |jonathan.druart@gmail.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200710|0 |1 is obsolete| | Attachment #200711|0 |1 is obsolete| | Attachment #200712|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=42529 --- Comment #29 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 200878 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200878&action=edit Bug 42529: Add Koha::Policy::Biblio::AgeRestriction This patch adds age restriction handling to the Koha namespace: - Koha::Biblio->age_restriction: metadata extractor that parses the agerestriction field using the AgeRestrictionMarker system preference. Returns the numeric age or undef. Uses single return with last pattern. - Koha::Policy::Biblio::AgeRestriction->check($biblio, $patron): policy class that evaluates whether a patron meets the age restriction. Returns a Koha::Result::Boolean (with payload on restriction). Test plan: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #30 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 200879 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200879&action=edit Bug 42529: Use Koha::Policy::Biblio::AgeRestriction for issuing and holds This patch updates CanBookBeIssued and CanItemBeReserved to use the new policy class instead of calling GetAgeRestriction directly. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t => SUCCESS: Tests pass! 2. Apply this patch 3. Repeat step 1 => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #31 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 200880 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200880&action=edit Bug 42529: Remove GetAgeRestriction from C4::Circulation GetAgeRestriction is no longer used by any caller. This patch removes it from the exports list and deletes the old test file. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/Circulation/AgeRestrictionMarkers.t => SUCCESS: Tests pass! 2. Apply this patch 3. Run: k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Amended-by: Jonathan Druart Removed this from the commit message: "The function body is kept for now as it is not harmful and could be used by third-party code. It is no longer exported." Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42529 --- Comment #32 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 200881 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200881&action=edit Bug 42529: Prevent the test to fail in the future Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org