Bugzilla – Attachment 155805 Details for
Bug 32942
Suggestion API doesn't support custom statuses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32942: (QA follow-up) Moving Suggestion->STATUS check to Suggestion::store
Bug-32942-QA-follow-up-Moving-Suggestion-STATUS-ch.patch (text/plain), 3.63 KB, created by
Martin Renvoize (ashimema)
on 2023-09-18 12:02:25 UTC
(
hide
)
Description:
Bug 32942: (QA follow-up) Moving Suggestion->STATUS check to Suggestion::store
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-09-18 12:02:25 UTC
Size:
3.63 KB
patch
obsolete
>From a175b6764652086a91a19fab665cc4c3e24cc601 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Fri, 18 Aug 2023 13:16:53 +0200 >Subject: [PATCH] Bug 32942: (QA follow-up) Moving Suggestion->STATUS check to > Suggestion::store > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Exceptions/Suggestion.pm | 49 +++++++++++++++++++++++++++++++++++ > Koha/REST/V1/Suggestions.pm | 4 --- > Koha/Suggestion.pm | 11 ++++++++ > 3 files changed, 60 insertions(+), 4 deletions(-) > create mode 100644 Koha/Exceptions/Suggestion.pm > >diff --git a/Koha/Exceptions/Suggestion.pm b/Koha/Exceptions/Suggestion.pm >new file mode 100644 >index 00000000000..04e50b18ede >--- /dev/null >+++ b/Koha/Exceptions/Suggestion.pm >@@ -0,0 +1,49 @@ >+package Koha::Exceptions::Suggestion; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Koha::Exception; >+ >+use Exception::Class ( >+ 'Koha::Exceptions::Suggestion' => { >+ isa => 'Koha::Exception', >+ }, >+ 'Koha::Exceptions::Suggestion::StatusForbidden' => { >+ isa => 'Koha::Exceptions::Suggestion', >+ description => 'This status is forbidden, check authorised values "SUGGEST"', >+ fields => ['STATUS'] >+ } >+); >+ >+=head1 NAME >+ >+Koha::Exceptions::Suggestion - Base class for Suggestion exceptions >+ >+=head1 Exceptions >+ >+=head2 Koha::Exceptions::Suggestion >+ >+Generic Suggestion exception >+ >+=head2 Koha::Exceptions::Suggestion::StatusIsUnknown >+ >+Exception to be used when a purchase suggestion tries to be saved and the status doesn't belong to the list of authorised_values. >+ >+=cut >+ >+1; >diff --git a/Koha/REST/V1/Suggestions.pm b/Koha/REST/V1/Suggestions.pm >index 67bcbe04fdf..ba21194a54b 100644 >--- a/Koha/REST/V1/Suggestions.pm >+++ b/Koha/REST/V1/Suggestions.pm >@@ -93,10 +93,6 @@ sub add { > > my $body = $c->req->json; > >- # FIXME: This should be handled in Koha::Suggestion->store >- $body->{'status'} = 'ASKED' >- unless defined $body->{'status'}; >- > my $overrides = $c->stash('koha.overrides'); > > unless ( $overrides->{any} ) { >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index b9fe4f1529e..f4d41566759 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -25,6 +25,8 @@ use C4::Letters; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Patrons; >+use Koha::AuthorisedValues; >+use Koha::Exceptions::Suggestion; > > use base qw(Koha::Object); > >@@ -49,6 +51,15 @@ sub store { > my ($self) = @_; > > $self->STATUS("ASKED") unless $self->STATUS; >+ my @status_constants = qw(ASKED CHECKED ACCEPTED REJECTED); >+ Koha::Exceptions::Suggestion::StatusForbidden->throw( STATUS => $self->STATUS ) >+ unless ( grep { $self->STATUS eq $_ } @status_constants ) >+ || Koha::AuthorisedValues->search( >+ { >+ category => 'SUGGEST_STATUS', >+ authorised_value => $self->STATUS >+ } >+ )->count; > > $self->branchcode(undef) if defined $self->branchcode && $self->branchcode eq ''; > unless ( $self->suggesteddate() ) { >-- >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 32942
:
146508
|
146592
|
146593
|
146594
|
154642
|
154643
|
155801
|
155802
|
155803
|
155804
| 155805 |
155806
|
155900
|
155901
|
155902
|
155903
|
155904
|
155905
|
155906