Bugzilla – Attachment 109974 Details for
Bug 17314
Routes to create, list and delete a purchase suggestion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17314: (QA follow-up)
Bug-17314-QA-follow-up.patch (text/plain), 4.23 KB, created by
Arthur Suzuki
on 2020-09-12 00:30:03 UTC
(
hide
)
Description:
Bug 17314: (QA follow-up)
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2020-09-12 00:30:03 UTC
Size:
4.23 KB
patch
obsolete
>From 0d2d5c1edbde44e2dc2373aff5d196321275506b Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Wed, 29 May 2019 10:53:21 +0200 >Subject: [PATCH] Bug 17314: (QA follow-up) > >Test plan unchanged >--- > Koha/REST/V1/Suggestions.pm | 18 ++++++++++++------ > api/v1/swagger/definitions/suggestion.json | 9 ++++----- > 2 files changed, 16 insertions(+), 11 deletions(-) > >diff --git a/Koha/REST/V1/Suggestions.pm b/Koha/REST/V1/Suggestions.pm >index fae6aff1a6..c5e3c4d8e9 100644 >--- a/Koha/REST/V1/Suggestions.pm >+++ b/Koha/REST/V1/Suggestions.pm >@@ -28,6 +28,7 @@ use Koha::Suggestions; > > use Koha::ItemTypes; > use Koha::Libraries; >+use List::MoreUtils qw/any/; > > use Try::Tiny; > >@@ -173,8 +174,8 @@ sub _validate_body { > } > > foreach my $param ( keys %{ $body } ) { >- unless (/^$param$/ ~~ @allowed_fields) { >- # Ouch ! Some mandatory field is missing! >+ unless (any { /^$param$/ } @allowed_fields) { >+ # Ouch ! User trying to edit field he has no rights to edit! > my $verb = 'specified '; > return $c->render( status => 403 , openapi => { > error => 'You ' . $verb . $param . ', but allowed fields are only ' . join(', ', @allowed_fields)} >@@ -183,9 +184,14 @@ sub _validate_body { > } > } > >+ # Set user's branchcode if not specified (after validation input, because user does not >+ # necessarily have rights to choose a branchcode) >+ if ( not exists $body->{branchcode} ) { >+ $body->{branchcode} = C4::Context->userenv->{branch}; >+ } > > # Is suggester anonymous? >- my $is_anonymous = not (defined $body->{suggestedby} and >+ my $is_anonymous = not (exists $body->{suggestedby} and > $body->{suggestedby} ne '' and > $body->{suggestedby} ne C4::Context->preference('AnonymousPatron')); > >@@ -215,21 +221,21 @@ sub _validate_body { > if ( exists $body->{itemtype} ) { > my @item_types = map {$_->unblessed->{itemtype}} Koha::ItemTypes->search; > return $c->render( status => 400 , openapi => {error => 'itemtype must be one of ' . join(', ', @item_types)} ) >- unless /^$body->{itemtype}$/ ~~ @item_types; >+ unless grep(/^$body->{itemtype}$/, @item_types); > } > > # Check branchcode is valid > if ( exists $body->{branchcode} ) { > my @branch_codes = map {$_->unblessed->{branchcode}} Koha::Libraries->search; > return $c->render( status => 400 , openapi => {error => 'branchcode must be one of ' . join(', ', @branch_codes)} ) >- unless /^$body->{branchcode}$/ ~~ @branch_codes; >+ unless grep(/^$body->{branchcode}$/, @branch_codes); > } > > # Check patron reason is valid > if ( exists $body->{patronreason} ) { > my @authorized_values = map { $_->{authorised_value} } @{ C4::Koha::GetAuthorisedValues('OPAC_SUG') }; > return $c->render( status => 400, openapi => {error => 'patronreason must be one of ' . join(', ', @authorized_values)} ) >- unless /^$body->{patronreason}$/ ~~ @authorized_values; >+ unless grep(/^$body->{patronreason}$/, @authorized_values); > } > > # Check suggestedby patron exists >diff --git a/api/v1/swagger/definitions/suggestion.json b/api/v1/swagger/definitions/suggestion.json >index b789d09961..2e4af794a8 100644 >--- a/api/v1/swagger/definitions/suggestion.json >+++ b/api/v1/swagger/definitions/suggestion.json >@@ -6,11 +6,11 @@ > "description": "unique identifier assigned automatically by Koha" > }, > "suggestedby": { >- "type": "string", >+ "type": ["string", "null"], > "description": "patron_id for the person making the suggestion, foreign key linking to the borrowers table" > }, > "suggesteddate": { >- "type": "string", >+ "type": ["string", "null"], > "description": "the suggestion was submitted" > }, > "managedby": { >@@ -70,7 +70,7 @@ > "description": "volume description" > }, > "publicationyear": { >- "type": "string", >+ "type": ["string", "null"], > "description": "year of publication" > }, > "place": { >@@ -126,6 +126,5 @@ > "description": "suggested total cost (price*quantity updated for currency)" > } > }, >- "additionalProperties": false, >- "required": ["title"] >+ "additionalProperties": false > } >-- >2.11.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 17314
:
58098
|
58100
|
58101
|
58993
|
60133
|
90171
|
90172
|
90176
|
91545
|
91546
|
93761
|
93762
|
93763
|
93764
|
93765
|
108380
|
109972
|
109973
|
109974
|
109975
|
109976
|
109977
|
114113
|
114114
|
114115
|
114116
|
114117
|
114118
|
120111
|
120133
|
120134
|
120135
|
120136
|
125097
|
125098
|
125099
|
125100
|
125101
|
125102
|
125103
|
125104
|
127533
|
127534
|
127535
|
127536