Bugzilla – Attachment 60133 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 followup 2nd
Bug-17314---QA-followup.patch (text/plain), 5.00 KB, created by
Jiri Kozlovsky
on 2017-02-12 17:48:27 UTC
(
hide
)
Description:
Bug 17314 - QA followup 2nd
Filename:
MIME Type:
Creator:
Jiri Kozlovsky
Created:
2017-02-12 17:48:27 UTC
Size:
5.00 KB
patch
obsolete
>From 6a553207f2f009390b198bdd11740ef9174657a0 Mon Sep 17 00:00:00 2001 >From: Jiri Kozlovsky <mail@jkozlovsky.cz> >Date: Sun, 12 Feb 2017 17:44:30 +0000 >Subject: [PATCH] Bug 17314 - QA followup > >Fixed: >Smartmatch >Updating suggestion when AnonSuggestions disabled >Not requiring title when updating >Branch choosing with respect to AllowPurchaseSuggestionBranchChoice > >Test plan unchanged >--- > Koha/REST/V1.pm | 4 ++-- > Koha/REST/V1/Suggestions.pm | 31 +++++++++++++++++++++++++----- > api/v1/swagger/definitions/suggestion.json | 3 +-- > 3 files changed, 29 insertions(+), 9 deletions(-) > >diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm >index 18ccb76..52fff69 100644 >--- a/Koha/REST/V1.pm >+++ b/Koha/REST/V1.pm >@@ -216,8 +216,8 @@ sub check_object_ownership { > borrowernumber => \&_object_ownership_by_borrowernumber, > checkout_id => \&_object_ownership_by_checkout_id, > reserve_id => \&_object_ownership_by_reserve_id, >- suggestionid => \&_object_ownership_by_suggestionid, >- suggestedby => \&_object_ownership_by_suggestedby, >+ suggestionid => \&_object_ownership_by_suggestionid, >+ suggestedby => \&_object_ownership_by_suggestedby, > }; > > foreach my $param ( keys %{ $parameters } ) { >diff --git a/Koha/REST/V1/Suggestions.pm b/Koha/REST/V1/Suggestions.pm >index da2fa6b..e82d791 100644 >--- a/Koha/REST/V1/Suggestions.pm >+++ b/Koha/REST/V1/Suggestions.pm >@@ -184,11 +184,24 @@ sub _validate_body { > join(', ', @allowed_fields)}, 403); > } > } >+ >+ # Set user's branchcode if not specified (after validation input, because user does not >+ # necessarily have rights to choose a branchcode) >+ if ( not $updating and not exists $body->{branchcode} ) { >+ $body->{branchcode} = C4::Context->userenv->{branch}; >+ } >+ > } > > if (not $updating) { > # Check for missing fields > my @mandatory_fields = split /,/, C4::Context->preference('OPACSuggestionMandatoryFields'); >+ >+ # Title is mandatory by default if none specified in settings >+ if (not @mandatory_fields) { >+ push (@mandatory_fields, 'title'); >+ } >+ > my @missing_fields = (); > for my $mandatory_field (@mandatory_fields) { > push(@missing_fields, $mandatory_field) if (not exists $body->{$mandatory_field}); >@@ -200,12 +213,20 @@ sub _validate_body { > } > > # 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')); > >+ # Is updated suggestedby anonymous? (Can be true only if "suggestedby" is defined!) >+ my $updated_is_anonymous = ( $updating and >+ exists $body->{suggestedby} and ( >+ $body->{suggestedby} eq '' or >+ $body->{suggestedby} eq C4::Context->preference('AnonymousPatron') >+ ) >+ ); >+ > # Refuse if are anonymous suggestions disabled >- if ( $is_anonymous ) { >+ if ( ($is_anonymous and not $updating) or $updated_is_anonymous ) { > return $c->$cb({error => 'Anonymous suggestions are disabled'}, 403) > unless C4::Context->preference('AnonSuggestions'); > } >@@ -230,21 +251,21 @@ sub _validate_body { > if ( exists $body->{itemtype} ) { > my @item_types = map {$_->unblessed->{itemtype}} Koha::ItemTypes->search; > return $c->$cb({error => 'itemtype must be one of ' . join(', ', @item_types)}, 400) >- 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->$cb({error => 'branchcode must be one of ' . join(', ', @branch_codes)}, 400) >- 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->$cb({error => 'patronreason must be one of ' . join(', ', @authorized_values)}, 400) >- 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 844354b..36a81cf 100644 >--- a/api/v1/swagger/definitions/suggestion.json >+++ b/api/v1/swagger/definitions/suggestion.json >@@ -126,6 +126,5 @@ > "description": "suggested total cost (price*quantity updated for currency)" > } > }, >- "additionalProperties": false, >- "required": ["title"] >+ "additionalProperties": false > } >-- >2.1.4
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