[Bug 43506] New: Add a way to copy opening hours from one library to another
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43506 Bug ID: 43506 Summary: Add a way to copy opening hours from one library to another 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: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Depends on: 43492 Target Milestone: --- There is currently no way to copy a library's opening hours (Bug 43492) to another library. A multi-branch system where several service points share identical hours (a consortium, or a new library going live with the same hours as a sister branch) has to re-enter every weekday/time-range/type combination by hand. Koha::Library::Calendar already solves the equivalent problem for holiday closures via copy_to and the REST /libraries/{id}/calendar/copy endpoint (Bug 42311). Opening hours should offer the same capability: a Koha::Library::OpeningHours->copy_to method, a REST endpoint following the same shape, and a UI action alongside the existing hours editor in Administration -> Libraries. Test plan: 1. Set up opening hours for library A, including at least one multi-day linked span. 2. Copy library A's hours to library B via the new action. 3. Confirm library B now has the same hours, correctly re-linked (not pointing at library A's row ids). 4. Confirm re-running the copy does not create duplicates. Depends on Bug 43492. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43492 [Bug 43492] Normalize library opening hours into a dedicated library_opening_hours table -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43506 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|43492 |43494 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43492 [Bug 43492] Normalize library opening hours into a dedicated library_opening_hours table https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43494 [Bug 43494] Add REST API endpoints for library opening hours -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43506 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43506 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 205429 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205429&action=edit Bug 43506: Add Koha::Library::OpeningHours->copy_to Adds a copy_to method mirroring Koha::Library::Calendar::copy_to, so a library's opening hours can be duplicated onto another library instead of being re-entered slot by slot. Copies in two passes: self-contained slots and open-ended openers first (building a source-id -> target-id map as they go), then close-only linked rows, re-pointing closes_opening_id at the *copy* of their opener rather than the source's row id. Idempotent, matching Calendar's copy_to - a slot already present on the target (matched on weekday/type/open_time/close_time, or for a linked closer, on its mapped opener id) is left alone rather than duplicated. Test plan: 1. prove t/db_dependent/Koha/Library/OpeningHours.t 2. Note the new "copy_to (Bug 43506)" subtest: copies a simple slot and a linked multi-day span (Friday opener / Monday closer) from one library to another, confirms the copy resolves correctly via resolved_intervals on the target, confirms re-running the copy does not duplicate anything, and confirms the source is untouched. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43506 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 205430 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205430&action=edit Bug 43506: Add REST endpoint and admin UI for copying opening hours Adds POST /libraries/{library_id}/opening_hours/copy, mirroring Koha::REST::V1::Libraries::Calendar's copy endpoint exactly (body {from_library_id}, 400/source_not_found for an unknown source, 201 with the Location header pointing back at the opening_hours collection). No route collision with GET/PUT/DELETE .../opening_hours/ {opening_hour_id}: verified directly against a running instance that Mojolicious's router prefers the literal "copy" segment over the integer placeholder regardless of declaration order, and the two only share the same HTTP method (POST) with a route that doesn't define it at all, so there was never any real ambiguity. Adds a "Copy hours from" control to the library edit form in Administration -> Libraries (edit only, not add - copying onto a library that doesn't exist yet makes no sense): a dropdown of every other library and a button that POSTs to the new endpoint and reloads the page on success. Verified end-to-end in-browser: seeded one library's GENERAL Monday 09:00-17:00 slot, copied it onto a second, empty library via the new control, and confirmed it appears correctly in that library's own hours table afterwards. Test plan: 1. prove t/db_dependent/api/v1/libraries_opening_hours.t 2. Note the new "copy() tests" subtest: copies a slot between two libraries via the API, confirms it's idempotent (no duplicates on a second copy), and confirms an unknown from_library_id surfaces as 400 source_not_found. 3. yarn build && restart_all, then in Administration -> Libraries, edit a library with no hours of its own, use "Copy hours from" to pick a library that does have hours, and confirm they appear. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org