https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42383 --- Comment #80 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 209740 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209740&action=edit Bug 42383: Add Koha::REST::Plugin::Policy This patch adds a Mojolicious plugin that provides the module_policy helper to any API controller. Usage: return $c->render( status => 403, openapi => { error => 'Return date override is not enabled', error_code => 'return_date_not_allowed', policy => $c->module_policy( 'Checkin', { library => $library_id } ), } ); The helper dynamically loads the appropriate Koha::Module::Policy subclass and returns the policy envelope for the authenticated user, so controllers can include it in the `policy` attribute of the error object when refusing a request because of it. This avoids duplicating the policy building logic across controllers. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/REST/Plugin/Policy.t => SUCCESS: Tests pass 3. Sign off :-D Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.