Bugzilla – Attachment 170000 Details for
Bug 37256
Add an endpoint to allow setting circulation rule sets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37256: Defined 'context' of circulation rules
Bug-37256-Defined-context-of-circulation-rules.patch (text/plain), 3.76 KB, created by
Martin Renvoize (ashimema)
on 2024-08-02 13:48:02 UTC
(
hide
)
Description:
Bug 37256: Defined 'context' of circulation rules
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-08-02 13:48:02 UTC
Size:
3.76 KB
patch
obsolete
>From 646864e19e838422110aad1a2c2b36382f2457fa Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 2 Aug 2024 14:19:18 +0100 >Subject: [PATCH] Bug 37256: Defined 'context' of circulation rules > >This is a follow-up to the previous bug exposing circulation rules over >the API. > >We formally define a definition for a circulation rules set including a >new 'context' object the defines the context, library_id, >patron_category_id and item_type_id combination of the rules returned. > >This is just a patch I missed in the last submission that I'd meant to >add and it's important for the PUT part of this patchset. >--- > Koha/REST/V1/CirculationRules.pm | 14 +++++++++++++- > .../definitions/circulation_rules.yaml | 19 +++++++++++++++++++ > api/v1/swagger/paths/circulation_rules.yaml | 2 +- > api/v1/swagger/swagger.yaml | 2 ++ > 4 files changed, 35 insertions(+), 2 deletions(-) > create mode 100644 api/v1/swagger/definitions/circulation_rules.yaml > >diff --git a/Koha/REST/V1/CirculationRules.pm b/Koha/REST/V1/CirculationRules.pm >index 41cb1cdf06a..92c38d7f84a 100644 >--- a/Koha/REST/V1/CirculationRules.pm >+++ b/Koha/REST/V1/CirculationRules.pm >@@ -50,7 +50,7 @@ sub list_rules { > my $c = shift->openapi->valid_input or return; > > return try { >- my $effective = $c->param('effective') // 1; >+ my $effective = $c->param('effective') // 1; > my $kinds = > defined( $c->param('rules') ) > ? [ split /\s*,\s*/, $c->param('rules') ] >@@ -157,6 +157,18 @@ sub list_rules { > > } > >+ # Map context into rules >+ @{$rules} = map { >+ my %new_rule = %$_; >+ my %context = ( >+ "library_id" => delete $new_rule{"branchcode"} // "*", >+ "patron_category_id" => delete $new_rule{"categorycode"} // "*", >+ "item_type_id" => delete $new_rule{"itemtype"} // "*", >+ ); >+ $new_rule{"context"} = \%context; >+ \%new_rule; >+ } @{$rules}; >+ > return $c->render( > status => 200, > openapi => $rules >diff --git a/api/v1/swagger/definitions/circulation_rules.yaml b/api/v1/swagger/definitions/circulation_rules.yaml >new file mode 100644 >index 00000000000..62f89fe4849 >--- /dev/null >+++ b/api/v1/swagger/definitions/circulation_rules.yaml >@@ -0,0 +1,19 @@ >+--- >+type: object >+properties: >+ context: >+ type: object >+ properties: >+ patron_category_id: >+ type: string >+ description: Patron category id >+ library_id: >+ type: string >+ description: Library branch id >+ item_type_id: >+ type: string >+ description: Item type id >+ description: Context of the ruleset >+additionalProperties: true >+required: >+ - context >diff --git a/api/v1/swagger/paths/circulation_rules.yaml b/api/v1/swagger/paths/circulation_rules.yaml >index 1c689e2ee09..53eadc17afb 100644 >--- a/api/v1/swagger/paths/circulation_rules.yaml >+++ b/api/v1/swagger/paths/circulation_rules.yaml >@@ -40,7 +40,7 @@ > schema: > type: array > items: >- type: object >+ $ref: "../swagger.yaml#/definitions/circulation_rules" > "400": > description: Bad request > schema: >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index dd72361380e..22418fd6fae 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -12,6 +12,8 @@ definitions: > $ref: ./definitions/authorised_value.yaml > authorised_value_category: > $ref: ./definitions/authorised_value_category.yaml >+ circulation_rules: >+ $ref: ./definitions/circulation_rules.yaml > identity_provider: > $ref: ./definitions/identity_provider.yaml > identity_provider_domain: >-- >2.45.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37256
:
170000
|
170001
|
170128
|
170129
|
170130
|
170152
|
170153
|
170154
|
170335
|
170336
|
170337
|
170338
|
171719
|
171720
|
171721
|
171722
|
171723
|
171724
|
171725
|
171726