Bugzilla – Attachment 156546 Details for
Bug 33690
Add ability to send welcome notice when creating patrons using the REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33690: Convert to x-koha-override
Bug-33690-Convert-to-x-koha-override.patch (text/plain), 3.10 KB, created by
Jonathan Druart
on 2023-10-04 13:54:05 UTC
(
hide
)
Description:
Bug 33690: Convert to x-koha-override
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-10-04 13:54:05 UTC
Size:
3.10 KB
patch
obsolete
>From b3b3b7a6f432f68c0a7b626300ea728ea03cbaa5 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 8 Sep 2023 12:06:26 +0100 >Subject: [PATCH] Bug 33690: Convert to x-koha-override > >This patch converts the existing work to use x-koha-override instead of >introducing an entirely new header and we default to the system >preference value if the override isn't passed. > >I believe this is more consistent with our approach in other areas of >koha to date. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/V1/Patrons.pm | 5 ++++- > api/v1/swagger/paths/patrons.yaml | 12 +++++++++--- > t/db_dependent/api/v1/patrons.t | 4 +++- > 3 files changed, 16 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index cfd8a083883..d89d47e1027 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -116,7 +116,10 @@ sub add { > > my $patron = Koha::Patron->new_from_api($body)->store; > >- if ( $c->req->headers->header('x-koha-welcome') ) { >+ my $overrides = $c->stash('koha.overrides'); >+ if ( $overrides->{welcome_yes} >+ || ( C4::Context->preference("AutoEmailNewUser") && !$overrides->{welcome_no} ) ) >+ { > > # if we manage to find a valid email address, send notice > if ( $patron->notice_email_address ) { >diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml >index 2245d381561..ff64e71bbbe 100644 >--- a/api/v1/swagger/paths/patrons.yaml >+++ b/api/v1/swagger/paths/patrons.yaml >@@ -405,11 +405,17 @@ > required: true > schema: > $ref: "../swagger.yaml#/definitions/patron" >- - name: x-koha-welcome >+ - name: x-koha-override > in: header > required: false >- description: If set to 'email' triggers the sending of a welcome email >- type: string >+ description: Overrides list sent as a request header >+ type: array >+ items: >+ type: string >+ enum: >+ - welcome_yes >+ - welcome_no >+ collectionFormat: csv > consumes: > - application/json > produces: >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 0d98ad0c982..3eb4e3e5255 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -408,8 +408,10 @@ subtest 'add() tests' => sub { > # Set a date-time field > $newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); > >+ t::lib::Mocks::mock_preference( 'AutoEmailNewUser', 0 ); > $letter_enqueued = 0; >- $t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron) >+ $t->post_ok( >+ "//$userid:$password@/api/v1/patrons" => { 'x-koha-override' => 'welcome_yes' } => json => $newpatron ) > ->status_is(201, 'Patron created successfully') > ->header_like( > Location => qr|^\/api\/v1\/patrons/\d*|, >-- >2.34.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 33690
:
150777
|
150787
|
150791
|
152642
|
155396
|
155397
|
155398
|
155406
|
155407
|
156544
|
156545
| 156546