Bugzilla – Attachment 135038 Details for
Bug 29566
Convert bundle contents modal to a notice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29566: Add API route for fetching item slip content
Bug-29566-Add-API-route-for-fetching-item-slip-con.patch (text/plain), 7.12 KB, created by
Martin Renvoize (ashimema)
on 2022-05-16 14:55:32 UTC
(
hide
)
Description:
Bug 29566: Add API route for fetching item slip content
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-05-16 14:55:32 UTC
Size:
7.12 KB
patch
obsolete
>From 70ca775185db11ccc3dfec2f5a30e70105377b5e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 24 Nov 2021 13:44:03 +0000 >Subject: [PATCH] Bug 29566: Add API route for fetching item slip content > >This patch adds an API endpoint to allow the generation and fetching of >an item print slip. >--- > Koha/REST/V1/Items.pm | 60 ++++++++++++++++++ > api/v1/swagger/definitions/slip.yaml | 18 ++++++ > api/v1/swagger/paths/items.yaml | 91 ++++++++++++++++++++++++++++ > api/v1/swagger/swagger.yaml | 4 ++ > 4 files changed, 173 insertions(+) > create mode 100644 api/v1/swagger/definitions/slip.yaml > >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 2e5478770f..59b4fa0292 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -20,6 +20,9 @@ use Modern::Perl; > use Mojo::Base 'Mojolicious::Controller'; > > use Koha::Items; >+use Koha::DateUtils qw( dt_from_string output_pref ); >+ >+use C4::Letters qw(GetPreparedLetter); > > use List::MoreUtils qw( any ); > use Try::Tiny qw( catch try ); >@@ -269,4 +272,61 @@ sub remove_from_bundle { > ); > } > >+=head3 print_slip >+ >+Controller function that handles constructing and returning the contents for a print slip for this item >+ >+=cut >+ >+sub print_slip { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $item_id = $c->validation->param('item_id'); >+ my $item = Koha::Items->find( $item_id ); >+ >+ unless ($item) { >+ return $c->render( >+ status => 404, >+ openapi => { error => "Item not found" } >+ ); >+ } >+ >+ my $print_slip_id = $c->validation->param('slip_id'); >+ >+ #FIXME: This should come from the session >+ my $user = $c->stash('koha.user'); >+ my $branchcode = $user->branchcode; >+ my $lang = $user->lang; >+ >+ my $slip = C4::Letters::GetPreparedLetter( >+ module => 'circulation', >+ letter_code => $print_slip_id, >+ branchcode => $branchcode, >+ message_transport_type => 'print', >+ #lang => $lang, >+ tables => { >+ items => $item_id >+ } >+ ); >+ >+ unless ($slip) { >+ return $c->render( >+ status => 404, >+ openapi => { error => "Slip not found" } >+ ); >+ } >+ >+ return $c->render( >+ status => 200, >+ openapi => { >+ timestamp => output_pref( >+ { dt => dt_from_string(), dateformat => 'rfc3339' } >+ ), >+ slip_id => $print_slip_id, >+ content => $slip->{content}, >+ title => $slip->{title} >+ } >+ ); >+} >+ > 1; >diff --git a/api/v1/swagger/definitions/slip.yaml b/api/v1/swagger/definitions/slip.yaml >new file mode 100644 >index 0000000000..96a6341b73 >--- /dev/null >+++ b/api/v1/swagger/definitions/slip.yaml >@@ -0,0 +1,18 @@ >+--- >+type: object >+properties: >+ slip_id: >+ type: string >+ readOnly: true >+ description: unique identifier code for the slip template >+ content: >+ type: string >+ description: Raw string content of the generated slip >+ title: >+ type: string >+ description: Raw string title of generated slip >+ timestamp: >+ type: string >+ format: date-time >+ description: timestamp of date the slip content was generated >+additionalProperties: false >diff --git a/api/v1/swagger/paths/items.yaml b/api/v1/swagger/paths/items.yaml >index 7c947f6e3f..d73a27be7d 100644 >--- a/api/v1/swagger/paths/items.yaml >+++ b/api/v1/swagger/paths/items.yaml >@@ -316,3 +316,94 @@ > x-koha-authorization: > permissions: > reserveforothers: place_holds >+/items/{item_id}/print_slips/{slip_id}: >+ get: >+ x-mojo-to: Items#print_slip >+ operationId: printSlipItems >+ tags: >+ - items >+ summary: Print slip for item as defined in notices and slips >+ parameters: >+ - $ref: ../swagger.yaml#/parameters#/item_id_pp >+ - name: slip_id >+ in: path >+ description: The required slip letter code identifier >+ required: true >+ type: string >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: A slip object >+ schema: >+ $ref: ../swagger.yaml#/definitions#/slip >+ "401": >+ description: Authentication required >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ "500": >+ description: Internal server error >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ x-koha-authorization: >+ permissions: >+ catalogue: "1" >+/public/items/{item_id}/bundled_items: >+ get: >+ x-mojo-to: Items#bundled_items >+ operationId: bundledItemsPublic >+ tags: >+ - items >+ summary: List bundled items >+ parameters: >+ - $ref: ../swagger.yaml#/parameters#/item_id_pp >+ - name: external_id >+ in: query >+ description: Search on the item's barcode >+ required: false >+ type: string >+ - $ref: ../swagger.yaml#/parameters#/match >+ - $ref: ../swagger.yaml#/parameters#/order_by >+ - $ref: ../swagger.yaml#/parameters#/page >+ - $ref: ../swagger.yaml#/parameters#/per_page >+ - $ref: ../swagger.yaml#/parameters#/q_param >+ - $ref: ../swagger.yaml#/parameters#/q_body >+ - $ref: ../swagger.yaml#/parameters#/q_header >+ consumes: >+ - application/json >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: A list of item >+ schema: >+ type: array >+ items: >+ $ref: ../swagger.yaml#/definitions#/item >+ "401": >+ description: Authentication required >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ "500": >+ description: Internal server error >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: ../swagger.yaml#/definitions#/error >+ x-koha-embed: >+ - biblio >+ - checkout >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 8b87cb5a59..08316adf9a 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -60,6 +60,8 @@ definitions: > $ref: ./definitions/quote.yaml > return_claim: > $ref: ./definitions/return_claim.yaml >+ slip: >+ $ref: ./definitions/slip.yaml > smtp_server: > $ref: ./definitions/smtp_server.yaml > suggestion: >@@ -161,6 +163,8 @@ paths: > $ref: ./paths/items.yaml#/~1items~1{item_id}~1bundled_items~1{bundled_item_id} > "/items/{item_id}/pickup_locations": > $ref: "./paths/items.yaml#/~1items~1{item_id}~1pickup_locations" >+ "/items/{item_id}/print_slips/{slip_id}": >+ $ref: "./paths/items.yaml#/~1items~1{item_id}~1print_slips~1{slip_id}" > /libraries: > $ref: ./paths/libraries.yaml#/~1libraries > "/libraries/{library_id}": >-- >2.20.1
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 29566
:
127983
|
127984
|
127985
|
135038
|
135039
|
135040
|
137511
|
137512
|
137513