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> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
6a9b4d9096
commit
f90715782c
3 changed files with 16 additions and 5 deletions
|
@ -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 ) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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*|,
|
||||
|
|
Loading…
Reference in a new issue