Bugzilla – Attachment 160712 Details for
Bug 35744
Implement +strings for GET /patrons/:patron_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35744: Implement +strings for GET /patrons/:patron_id
Bug-35744-Implement-strings-for-GET-patronspatroni.patch (text/plain), 4.09 KB, created by
Owen Leonard
on 2024-01-09 16:53:31 UTC
(
hide
)
Description:
Bug 35744: Implement +strings for GET /patrons/:patron_id
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2024-01-09 16:53:31 UTC
Size:
4.09 KB
patch
obsolete
>From b460d00f39e3161d362ae2aa50eb06d5e671f3c5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 Jan 2024 13:14:55 +0100 >Subject: [PATCH] Bug 35744: Implement +strings for GET /patrons/:patron_id > >In order to retrieve the library's name and patron category's >description alongwith other patron's info. > >Test plan: >Run the following command before and after this patch: > >% curl -u koha:koha --request GET 'http://localhost:8081/api/v1/patrons/42' --header "Content-Type: application/json" --header "x-koha-embed: +strings" | jq > >Notice that you now have _strings which contains the library's name and >patron category's description > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > Koha/Patron.pm | 21 +++++++++++++++++++ > api/v1/swagger/definitions/patron.yaml | 5 +++++ > api/v1/swagger/paths/patrons.yaml | 1 + > t/db_dependent/api/v1/patrons.t | 29 +++++++++++++++++++++++++- > 4 files changed, 55 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 1a4a920580..758c4e21ad 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2467,6 +2467,27 @@ sub to_api_mapping { > }; > } > >+=head3 strings_map >+ >+Returns a map of column name to string representations including the string. >+ >+=cut >+ >+sub strings_map { >+ my ( $self, $params ) = @_; >+ >+ return { >+ library_id => { >+ str => $self->library->branchname, >+ type => 'library', >+ }, >+ category_id => { >+ str => $self->category->description, >+ type => 'patron_category', >+ } >+ }; >+} >+ > =head3 queue_notice > > Koha::Patrons->queue_notice({ letter_params => $letter_params, message_name => 'DUE'}); >diff --git a/api/v1/swagger/definitions/patron.yaml b/api/v1/swagger/definitions/patron.yaml >index edcf47beec..26f7b81948 100644 >--- a/api/v1/swagger/definitions/patron.yaml >+++ b/api/v1/swagger/definitions/patron.yaml >@@ -378,6 +378,11 @@ properties: > type: > - boolean > description: Protected status of the patron >+ _strings: >+ type: >+ - object >+ - "null" >+ description: A list of stringified coded values > additionalProperties: false > required: > - surname >diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml >index cf8aa09122..a2e86ec2a8 100644 >--- a/api/v1/swagger/paths/patrons.yaml >+++ b/api/v1/swagger/paths/patrons.yaml >@@ -482,6 +482,7 @@ > items: > type: string > enum: >+ - +strings > - extended_attributes > collectionFormat: csv > produces: >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index f882cae0e0..1e3acdf306 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -230,7 +230,7 @@ subtest 'list() tests' => sub { > > subtest 'get() tests' => sub { > >- plan tests => 3; >+ plan tests => 4; > > $schema->storage->txn_begin; > unauthorized_access_tests('GET', -1, undef); >@@ -315,6 +315,33 @@ subtest 'get() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest '+strings' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 2**4 } # borrowers flag = 4 >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id => { "x-koha-embed" => "+strings" } ) >+ ->status_is(200) >+ ->json_has( '/_strings/library_id' => { str => $patron->library->branchname, type => 'library' } ) >+ ->json_has( >+ '/_strings/category_id' => { str => $patron->category->description, type => 'patron_category' } ); >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'add() tests' => sub { >-- >2.30.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 35744
:
160696
|
160712
|
161088