Bugzilla – Attachment 132622 Details for
Bug 30055
Rewrite some of the patron searches to make them use the REST API routes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30055: /api/v1/acquisitions/funds/owners and users for funds
Bug-30055-apiv1acquisitionsfundsowners-and-users-f.patch (text/plain), 12.88 KB, created by
Séverine Queune
on 2022-03-30 14:03:51 UTC
(
hide
)
Description:
Bug 30055: /api/v1/acquisitions/funds/owners and users for funds
Filename:
MIME Type:
Creator:
Séverine Queune
Created:
2022-03-30 14:03:51 UTC
Size:
12.88 KB
patch
obsolete
>From 1ddb6b4ea0173cb1b884d937ee93bd59e4e67363 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 9 Feb 2022 12:58:28 +0100 >Subject: [PATCH] Bug 30055: /api/v1/acquisitions/funds/owners and users for > funds >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Two new routes that do the same thing >/api/v1/acquisitions/funds/owners >/api/v1/acquisitions/funds/users >To list the possible owners and users for a fund > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Séverine Queune <severine.queune@bulac.fr> >--- > Koha/REST/V1/Acquisitions/Funds.pm | 48 +++++++++++ > admin/add_user_search.pl | 65 -------------- > api/v1/swagger/paths/acquisitions_funds.yaml | 86 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 4 + > .../modules/acqui/tables/members_results.tt | 26 ------ > .../prog/en/modules/admin/aqbudgets.tt | 4 +- > .../prog/en/modules/members/search.tt | 4 + > 7 files changed, 144 insertions(+), 93 deletions(-) > delete mode 100755 admin/add_user_search.pl > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt > >diff --git a/Koha/REST/V1/Acquisitions/Funds.pm b/Koha/REST/V1/Acquisitions/Funds.pm >index c4209289fe..59f9f3577f 100644 >--- a/Koha/REST/V1/Acquisitions/Funds.pm >+++ b/Koha/REST/V1/Acquisitions/Funds.pm >@@ -55,4 +55,52 @@ sub list { > }; > } > >+=head3 list_owners >+ >+Return the list of possible funds' owners >+ >+=cut >+ >+sub list_owners { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ >+ my $patrons_rs = Koha::Patrons->search->filter_by_have_subpermission('acquisition.budget_modify'); >+ my $patrons = $c->objects->search( $patrons_rs ); >+ >+ return $c->render( >+ status => 200, >+ openapi => $patrons >+ ); >+ } >+ catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+=head3 list_users >+ >+Return the list of possible funds' users >+ >+=cut >+ >+sub list_users { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ >+ my $patrons_rs = Koha::Patrons->search->filter_by_have_subpermission('acquisition.budget_modify'); >+ my $patrons = $c->objects->search( $patrons_rs ); >+ >+ return $c->render( >+ status => 200, >+ openapi => $patrons >+ ); >+ } >+ catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ > 1; >diff --git a/admin/add_user_search.pl b/admin/add_user_search.pl >deleted file mode 100755 >index 032301a6d7..0000000000 >--- a/admin/add_user_search.pl >+++ /dev/null >@@ -1,65 +0,0 @@ >-#!/usr/bin/perl >- >-# This file is part of Koha. >-# >-# Copyright 2014 BibLibre >-# >-# 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 CGI qw ( -utf8 ); >-use C4::Auth qw( get_template_and_user ); >-use C4::Output qw( output_html_with_http_headers ); >-use C4::Members; >- >-use Koha::Patron::Categories; >- >-my $input = CGI->new; >- >-my $dbh = C4::Context->dbh; >- >-my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( >- { template_name => "common/patron_search.tt", >- query => $input, >- type => "intranet", >- flagsrequired => { acquisition => 'budget_modify' }, >- } >-); >- >-my $q = $input->param('q') || ''; >-my $op = $input->param('op') || ''; >-my $selection_type = $input->param('selection_type') || 'add'; >- >-my $referer = $input->referer(); >- >-# If this script is called by admin/aqbudgets.pl >-# the patrons to return should be superlibrarian or have the order_manage >-# acquisition flag. >-my $search_patrons_with_acq_perm_only = >- ( $referer =~ m|admin/aqbudgets.pl| ) >- ? 1 : 0; >- >-my $patron_categories = Koha::Patron::Categories->search_with_library_limits; >-$template->param( >- patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only, >- view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", >- columns => ['cardnumber', 'name', 'branch', 'category', 'action'], >- json_template => 'acqui/tables/members_results.tt', >- selection_type => $selection_type, >- alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), >- categories => $patron_categories, >- aaSorting => 1, >-); >-output_html_with_http_headers( $input, $cookie, $template->output ); >diff --git a/api/v1/swagger/paths/acquisitions_funds.yaml b/api/v1/swagger/paths/acquisitions_funds.yaml >index 9dd00ef4b7..188c91e537 100644 >--- a/api/v1/swagger/paths/acquisitions_funds.yaml >+++ b/api/v1/swagger/paths/acquisitions_funds.yaml >@@ -59,3 +59,89 @@ > x-koha-authorization: > permissions: > acquisition: budget_manage_all >+/acquisitions/funds/owners: >+ get: >+ x-mojo-to: Acquisitions::Funds#list_owners >+ operationId: listFundsOwners >+ description: This resource returns a list of patron allowed to be owner of funds >+ summary: List possibe owners for funds >+ tags: >+ - funds >+ parameters: >+ - $ref: ../parameters.yaml#/match >+ - $ref: ../parameters.yaml#/order_by >+ - $ref: ../parameters.yaml#/page >+ - $ref: ../parameters.yaml#/per_page >+ - $ref: ../parameters.yaml#/q_param >+ - $ref: ../parameters.yaml#/q_body >+ - $ref: ../parameters.yaml#/q_header >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: A list of funds' owners >+ schema: >+ type: array >+ items: >+ $ref: ../definitions.yaml#/patron >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: ../definitions.yaml#/error >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: ../definitions.yaml#/error >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: ../definitions.yaml#/error >+ x-koha-authorization: >+ permissions: >+ acquisition: budget_modify >+/acquisitions/funds/users: >+ get: >+ x-mojo-to: Acquisitions::Funds#list_users >+ operationId: listFundsUsers >+ description: This resource returns a list of patron allowed to be owner of funds >+ summary: List possibe users for funds >+ tags: >+ - funds >+ parameters: >+ - $ref: ../parameters.yaml#/match >+ - $ref: ../parameters.yaml#/order_by >+ - $ref: ../parameters.yaml#/page >+ - $ref: ../parameters.yaml#/per_page >+ - $ref: ../parameters.yaml#/q_param >+ - $ref: ../parameters.yaml#/q_body >+ - $ref: ../parameters.yaml#/q_header >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: A list of funds' users >+ schema: >+ type: array >+ items: >+ $ref: ../definitions.yaml#/patron >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: ../definitions.yaml#/error >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: ../definitions.yaml#/error >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: ../definitions.yaml#/error >+ x-koha-authorization: >+ permissions: >+ acquisition: budget_modify >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 9564dba35d..b724868c0c 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -69,6 +69,10 @@ paths: > $ref: paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets~1managers > /acquisitions/funds: > $ref: ./paths/acquisitions_funds.yaml#/~1acquisitions~1funds >+ /acquisitions/funds/owners: >+ $ref: paths/acquisitions_funds.yaml#/~1acquisitions~1funds~1owners >+ /acquisitions/funds/users: >+ $ref: paths/acquisitions_funds.yaml#/~1acquisitions~1funds~1users > /acquisitions/orders: > $ref: ./paths/acquisitions_orders.yaml#/~1acquisitions~1orders > "/acquisitions/orders/{order_id}": >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt >deleted file mode 100644 >index 50cc702350..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt >+++ /dev/null >@@ -1,26 +0,0 @@ >-[% USE To %] >-{ >- "sEcho": [% sEcho | html %], >- "iTotalRecords": [% iTotalRecords | html %], >- "iTotalDisplayRecords": [% iTotalDisplayRecords | html %], >- "aaData": [ >- [% FOREACH data IN aaData %] >- { >- "dt_cardnumber": >- "[% data.cardnumber | html %]", >- "dt_name": >- "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber | html %]\" class=\"patron_preview\" data-borrowernumber=\"[% data.borrowernumber | html %]\" style='white-space:nowrap'>[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = To.json(data.firstname) surname = To.json(data.surname) othernames = To.json(data.othernames) cardnumber = data.cardnumber invert_name = 1%]</a>", >- "dt_branch": >- "[% data.branchname | html %]", >- "dt_category": >- "[% data.category_description | html %] <span class=\"patron_category_type\">([% data.category_type | html %])</span>", >- "dt_action": >- [%- IF selection_type == 'select' -%] >- "<a class=\"btn btn-default btn-xs select_user\" href=\"#\" data-borrowernumber=\"[% data.borrowernumber | html %]\" data-borrowerdata=\"[% To.json(data) | html %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber | html %]\" name=\"borrower_data[% data.borrowernumber | html %]\" value=\"[% To.json(data) | html %]\" />" >- [%- ELSE -%] >- "<a href=\"#\" data-borrowernumber=\"[% data.borrowernumber | html %]\" data-firstname=\"[% data.firstname | html %]\" data-surname=\"[% data.surname | html %]\" class=\"btn btn-default btn-xs add_user\"><i class=\"fa fa-plus\"></i> Add</a>" >- [%- END -%] >- }[% UNLESS loop.last %],[% END %] >- [% END %] >- ] >-} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt >index d7f15fe08d..347f79f9c6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt >@@ -495,7 +495,7 @@ > //<![CDATA[ > > function userPopup() { >- window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add", >+ window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users", > 'PatronPopup', > 'width=740,height=450,location=yes,toolbar=no,' > + 'scrollbars=yes,resize=yes' >@@ -503,7 +503,7 @@ > } > > function ownerPopup() { >- window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select", >+ window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners", > 'PatronPopup', > 'width=740,height=450,location=yes,toolbar=no,' > + 'scrollbars=yes,resize=yes' >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >index 51a3f8aa60..31ec421a0a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >@@ -169,6 +169,10 @@ > "url": '/api/v1/suggestions/managers' > [% CASE 'baskets_managers' %] > "url": '/api/v1/acquisitions/baskets/managers' >+ [% CASE 'funds_owners' %] >+ "url": '/api/v1/acquisitions/funds/owners' >+ [% CASE 'funds_users' %] >+ "url": '/api/v1/acquisitions/funds/users' > [% CASE %] > "url": '/api/v1/patrons' > [% END %] >-- >2.30.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 30055
:
130364
|
130365
|
130366
|
130367
|
130368
|
130369
|
130370
|
130371
|
130372
|
130385
|
130386
|
130387
|
130388
|
130389
|
130390
|
130391
|
130392
|
130393
|
130394
|
130395
|
130457
|
130487
|
130488
|
130491
|
130507
|
130511
|
130629
|
130630
|
130671
|
130672
|
130701
|
130702
|
130704
|
130716
|
130717
|
131829
|
132168
|
132419
|
132420
|
132421
|
132422
|
132423
|
132424
|
132425
|
132426
|
132427
|
132428
|
132429
|
132430
|
132431
|
132432
|
132433
|
132434
|
132435
|
132436
|
132437
|
132438
|
132439
|
132440
|
132441
|
132450
|
132451
|
132452
|
132453
|
132454
|
132455
|
132456
|
132457
|
132458
|
132459
|
132460
|
132461
|
132462
|
132463
|
132464
|
132465
|
132466
|
132467
|
132468
|
132469
|
132470
|
132471
|
132472
|
132473
|
132539
|
132616
|
132617
|
132618
|
132619
|
132620
|
132621
|
132622
|
132623
|
132624
|
132625
|
132627
|
132628
|
132629
|
132630
|
132631
|
132632
|
132633
|
132634
|
132635
|
132636
|
132637
|
132638
|
132639
|
132640
|
132641
|
132664
|
132665
|
132666
|
132667
|
132668
|
132669
|
132670
|
132671
|
132672
|
132673
|
132674
|
132675
|
132676
|
132677
|
132678
|
132679
|
132680
|
132681
|
132682
|
132683
|
132684
|
132685
|
132686
|
132687
|
132688