Bugzilla – Attachment 96943 Details for
Bug 24321
Make objects.search use mappings from Koha::Object(s)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24321: Clean /acquisitions/funds
Bug-24321-Clean-acquisitionsfunds.patch (text/plain), 5.41 KB, created by
Kyle M Hall (khall)
on 2020-01-07 18:50:14 UTC
(
hide
)
Description:
Bug 24321: Clean /acquisitions/funds
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-01-07 18:50:14 UTC
Size:
5.41 KB
patch
obsolete
>From bb926c4b42baf840a3b74c31016e0d736502d903 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 31 Dec 2019 10:42:38 -0300 >Subject: [PATCH] Bug 24321: Clean /acquisitions/funds > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/V1/Acquisitions/Funds.pm | 88 ++------------------ > api/v1/swagger/paths/acquisitions_funds.json | 14 +++- > 2 files changed, 22 insertions(+), 80 deletions(-) > >diff --git a/Koha/REST/V1/Acquisitions/Funds.pm b/Koha/REST/V1/Acquisitions/Funds.pm >index 21f5e4bacf..fe3f7da3e4 100644 >--- a/Koha/REST/V1/Acquisitions/Funds.pm >+++ b/Koha/REST/V1/Acquisitions/Funds.pm >@@ -29,37 +29,25 @@ Koha::REST::V1::Acquisitions::Funds > > =head1 API > >-=head2 Methods >+=head2 Class methods > >-=head3 list_funds >+=head3 list > > Controller function that handles listing Funds > > =cut > >-sub list_funds { >+sub list { > my $c = shift->openapi->valid_input or return; > >- my $args = _to_model($c->req->params->to_hash); >- my $filter; >- >- for my $filter_param ( keys %$args ) { >- if ($args->{$filter_param}) { >- if ($filter_param eq "budget_owner_id") { >- # Perform an exact search on the borrowernumber >- $filter->{$filter_param} = { "=" => $args->{$filter_param} } >- } else { >- # And a "start with" search on the budget name >- $filter->{$filter_param} = { LIKE => $args->{$filter_param} . "%" } >- } >- } >- } >- > return try { >- my $funds = Koha::Acquisition::Funds->search($filter); >+ >+ my $funds_rs = Koha::Acquisition::Funds->new; >+ my $funds = $c->objects->search( $funds_rs ); >+ > return $c->render( > status => 200, >- openapi => $funds->to_api >+ openapi => $funds > ); > } > catch { >@@ -69,67 +57,9 @@ sub list_funds { > } > else { > return $c->render( status => 500, >- openapi => { error => "Something went wrong, check the logs. $_ $filter" } ); >+ openapi => { error => "Something went wrong, check the logs. $_" } ); > } > }; > } > >-=head3 _to_api >- >-Helper function that maps a Fund into >-the attribute names the exposed REST api spec. >- >-=cut >- >-sub _to_api { >- my $fund = shift; >- my $returnfund; >- $returnfund->{fund_id} = delete $fund->{budget_id}; >- $returnfund->{code} = delete $fund->{budget_code}; >- $returnfund->{name} = delete $fund->{budget_name}; >- $returnfund->{library_id} = delete $fund->{budget_branchcode}; >- $returnfund->{total_amount} = delete $fund->{budget_amount}; >- $returnfund->{warn_at_percentage} = delete $fund->{budget_encumb}; >- $returnfund->{warn_at_amount} = delete $fund->{budget_expend}; >- $returnfund->{notes} = delete $fund->{budget_notes}; >- $returnfund->{budget_id} = delete $fund->{budget_period_id}; >- $returnfund->{timestamp} = delete $fund->{timestamp}; >- $returnfund->{fund_owner_id} = delete $fund->{budget_owner_id}; >- $returnfund->{fund_access} = delete $fund->{budget_permission}; >- $returnfund->{statistic1_auth_value_category} = delete $fund->{sort1_authcat}; >- $returnfund->{statistic2_auth_value_category} = delete $fund->{sort2_authcat}; >- >- return $returnfund; >-} >- >-=head3 _to_model >- >-Helper function that maps REST api objects into Fund >-attribute names. >- >-=cut >- >-sub _to_model { >- my $fund = shift; >- my $returnfund; >- >- # Rename back >- $returnfund->{budget_id} = delete $fund->{fund_id}; >- $returnfund->{budget_code} = delete $fund->{code}; >- $returnfund->{budget_name} = delete $fund->{name}; >- $returnfund->{budget_branchcode} = delete $fund->{library_id}; >- $returnfund->{budget_amount} = delete $fund->{total_amount}; >- $returnfund->{budget_encumb} = delete $fund->{warn_at_percentage}; >- $returnfund->{budget_expend} = delete $fund->{warn_at_amount}; >- $returnfund->{budget_notes} = delete $fund->{notes}; >- $returnfund->{budget_period_id} = delete $fund->{budget_id}; >- $returnfund->{budget_owner_id} = delete $fund->{fund_owner_id}; >- $returnfund->{timestamp} = delete $fund->{timestamp}; >- $returnfund->{budget_permission} = delete $fund->{fund_access}; >- $returnfund->{sort1_authcat} = delete $fund->{statistic1_auth_value_category}; >- $returnfund->{sort2_authcat} = delete $fund->{statistic2_auth_value_category}; >- >- return $returnfund; >-} >- > 1; >diff --git a/api/v1/swagger/paths/acquisitions_funds.json b/api/v1/swagger/paths/acquisitions_funds.json >index 44f72774a2..1b0ebce147 100644 >--- a/api/v1/swagger/paths/acquisitions_funds.json >+++ b/api/v1/swagger/paths/acquisitions_funds.json >@@ -1,7 +1,7 @@ > { > "/acquisitions/funds": { > "get": { >- "x-mojo-to": "Acquisitions::Funds#list_funds", >+ "x-mojo-to": "Acquisitions::Funds#list", > "operationId": "listFunds", > "tags": ["acquisitions","funds"], > "produces": [ >@@ -20,6 +20,18 @@ > "description": "Display only the funds that belongs to the given patron ID", > "required": false, > "type": "integer" >+ }, >+ { >+ "$ref": "../parameters.json#/match" >+ }, >+ { >+ "$ref": "../parameters.json#/order_by" >+ }, >+ { >+ "$ref": "../parameters.json#/page" >+ }, >+ { >+ "$ref": "../parameters.json#/per_page" > } > ], > "responses": { >-- >2.21.0 (Apple Git-122.2)
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 24321
:
96703
|
96704
|
96705
|
96706
|
96707
|
96708
|
96709
|
96710
|
96711
|
96712
|
96713
|
96714
|
96715
|
96716
|
96717
|
96718
|
96719
|
96720
|
96721
|
96722
|
96744
|
96840
|
96841
|
96842
|
96843
|
96844
|
96845
|
96846
|
96847
|
96848
|
96849
|
96850
|
96851
|
96852
|
96874
|
96875
|
96876
|
96877
|
96878
|
96879
|
96880
|
96881
|
96882
|
96883
|
96884
|
96885
|
96886
|
96887
|
96939
|
96940
|
96941
|
96942
| 96943 |
96944
|
96945
|
96946
|
96947
|
96948
|
96949
|
96950
|
96951
|
96952