Bugzilla – Attachment 74640 Details for
Bug 20600
Provide the ability for users to filter ILL requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20600: API - Format dates according to syspref
Bug-20600-API---Format-dates-according-to-syspref.patch (text/plain), 2.40 KB, created by
Andrew Isherwood
on 2018-04-20 13:32:21 UTC
(
hide
)
Description:
Bug 20600: API - Format dates according to syspref
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2018-04-20 13:32:21 UTC
Size:
2.40 KB
patch
obsolete
>From 05283f26f0e23ff19060c1ab3219411d6a1d22df Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Fri, 20 Apr 2018 14:20:11 +0100 >Subject: [PATCH] Bug 20600: API - Format dates according to syspref > >Dates supplied by the /api/v1/illrequests API route were not conforming >to the preference specified by the dateformat syspref. This patch >addresses that. > >It has been addressed as part of this bug since we are adding filtering >of requests by some date fields and, therefore, needed dates in a >predictable format. > >To test: >1) Apply the patch >2) Ensure you have at least one ILL request created >3) Make a request to the /api/v1/illrequests endpoint >4) Observe that dates supplied for "placed" & "updated" conform to your >dateformat syspref. >5) Change your date format syspref, repeat steps 3 & 4 >--- > Koha/REST/V1/Illrequests.pm | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > >diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm >index 6e3eace01d..34fece7ed3 100644 >--- a/Koha/REST/V1/Illrequests.pm >+++ b/Koha/REST/V1/Illrequests.pm >@@ -21,6 +21,7 @@ use Mojo::Base 'Mojolicious::Controller'; > > use Koha::Illrequests; > use Koha::Libraries; >+use Koha::DateUtils qw( format_sqldatetime ); > > =head1 NAME > >@@ -40,6 +41,7 @@ sub list { > my $args = $c->req->params->to_hash // {}; > my $filter; > my $output = []; >+ my @format_dates = ( 'placed', 'updated' ); > > # Create a hash where all keys are embedded values > # Enables easy checking >@@ -54,18 +56,25 @@ sub list { > $filter->{$filter_param} = \@values; > } > >- my $requests = Koha::Illrequests->search($filter); >+ my @req_list = Koha::Illrequests->search($filter)->as_list; > > if ( scalar (keys %embed) ) > { > # Need to embed stuff >- my @results = map { $_->TO_JSON(\%embed) } $requests->as_list; >- return $c->render( status => 200, openapi => \@results ); >+ @req_list = map { $_->TO_JSON(\%embed) } @req_list; > } >- else >- { >- return $c->render( status => 200, openapi => $requests ); >+ >+ # Format dates as required >+ foreach(@req_list) { >+ foreach my $field(@format_dates) { >+ if (defined $_->{$field}) { >+ $_->{$field} = format_sqldatetime($_->{$field}, undef, undef, 1); >+ } >+ } >+ > } >+ >+ return $c->render( status => 200, openapi => \@req_list ); > } > > 1; >-- >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 20600
:
74640
|
74641
|
75202
|
75276
|
75734
|
75735
|
75753
|
75755
|
75844
|
75845
|
75848
|
75849
|
75850
|
75851
|
75852
|
75853
|
75854
|
75871
|
77691
|
77692
|
77693
|
77694
|
77695
|
77696
|
77697
|
78439
|
78440
|
78441
|
78442
|
78443
|
78444
|
78445
|
78446
|
78463
|
78464
|
78465
|
78466
|
78467
|
78468
|
78469
|
78470
|
79183
|
80468
|
81992
|
81993
|
82032
|
82033
|
82034
|
82035
|
82036
|
82037
|
82038
|
82039
|
82062
|
82170
|
82171
|
82432
|
82433
|
82434
|
82435
|
82436
|
82437
|
82438
|
82439
|
82440
|
82441
|
82442
|
83882
|
83887
|
84736
|
84737
|
84738
|
84739
|
84740
|
84741
|
84742
|
84743
|
84744
|
84745
|
84746
|
84747
|
84748
|
84749
|
85037
|
85038
|
85039
|
85040
|
85041
|
85042
|
85043
|
85044
|
85045
|
85046
|
85047
|
85048
|
85049
|
85050