Bugzilla – Attachment 155398 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), 2.97 KB, created by
Martin Renvoize
on 2023-09-08 11:10:50 UTC
(
hide
)
Description:
Bug 33690: Convert to x-koha-override
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2023-09-08 11:10:50 UTC
Size:
2.97 KB
patch
obsolete
>From 443f023bedb132afd80501bba6653ede05e15175 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. >--- > Koha/REST/V1/Patrons.pm | 3 ++- > api/v1/swagger/paths/patrons.yaml | 12 +++++++++--- > t/db_dependent/api/v1/patrons.t | 3 ++- > 3 files changed, 13 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index cfd8a08388..637ccef15e 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -116,7 +116,8 @@ 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 2245d38156..ff64e71bbb 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 befd960fe9..8e5d258637 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -398,8 +398,9 @@ 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.41.0
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