Commit graph

30364 commits

Author SHA1 Message Date
Jessica Freeman
eddc1acd70 Bug 19714: Removing 2 occurrences of memberofinstitution
To Test:
1/grep for memberofinstitution
2/Notice it occurs in C4/UsageStats.pm and t/db_dependent/UsageStats.t
3/grep again, notice they have been removed

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-19 11:15:54 -03:00
Chris Weeks
e243c36db6 Bug 19510: Add description for edi_manage in acquistion permissions
Test Plan:
1/ Login
2/ Select patrons
3/ Search for a patron by name or card number that exists in the system
4/ Click More -> Set permissions
5/ Expand 'acquistions' and notice that 'edi_manage' has no description
6/ Apply patch
7/ Refresh the permissions page or repeat steps 2 to 5.
8/ Notice that 'edi_manage' now has a description of 'Manage EDIFACT transmissions'

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-19 11:13:12 -03:00
130ace3899 Bug 19759: Fix failing test in Chargelostitem.t
t/db_dependent/Circulation/Chargelostitem.t .. 1/6
 #   Failed test 'The accountline amount should be precessfee value '
 #   at t/db_dependent/Circulation/Chargelostitem.t line 71.
 #          got: '4.5968041848873e+20'
 #     expected: '459680418488730451968.00'

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 14:48:53 -03:00
Julian Maurice
6325f9ed55 Bug 19444: (QA follow-up) Remove repeating condition
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:27 -03:00
Julian Maurice
4a439d0528 Bug 19444: (QA follow-up) Fix tests for UNIMARC
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:26 -03:00
25e050e2ef Bug 19444: Display error message for auto_account_expired
Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:26 -03:00
a8f4aacb1d Bug 19444: Do not auto renew if patron is expired and BlockExpiredPatronOpacActions is set
If the patron's account has expired and BlockExpiredPatronOpacActions is set,
we expect auto renewal to be rejected.

Test plan:
Use the automatic_renewals.pl cronjob script to auto renew a checkout

Before this patch, if the patron's account has expired the auto renew was done.
With this patch, it will only be auto renewed if BlockExpiredPatronOpacActions is not set.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:26 -03:00
dcc2c5e2d9 Bug 19805: Add DataTables to Koha to MARC mapping page
This patch adds sorting and filtering to the Koha to MARC mapping table
using DataTables.

Also changed: Font awesome icons on "Add" and "Remove" buttons; Minor
markup correction to breadcrumbs.

To test, apply the patch and go to Administration -> Koha to MARC
mapping.

- Table should be sorted by default on Koha field.
- Sorting and filtering should work correctly.

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:26 -03:00
d3cc2a1a9d Bug 19654: Move tools templates JavaScript to the footer: Batch MARC tools
This patch modifies the staff client patron lists templates so that
JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of
each modified template: All button controls, DataTables functionality,
form validation, etc.

Revised: My original patch included changes to batchMod-edit.tt but
didn't take into account the MARC plugins which are loaded in the item
edit form. I have discarded those changes for now.

Tools -> Batch record modification
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
  - Submit records for deletion
    - Page highlighting in the sidebar
    - Checkbox selection links
    - Warning when no records selected
    - Patron autocomplete in the "Check out" tab
Tools -> Batch item modification
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
Tools -> Batch item deletion
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
  - Submit items for deletion
    - Patron autocomplete in the "Check out" tab
    - Checkbox selection links
    - Column-hiding checkboxes
    - Datatables
Tools -> Batch record modification
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
  - Submit records for modification
      - Page highlighting in the sidebar
      - Patron autocomplete in the "Check out" tab
      - Checkbox selection links
      - Datatables
      - MARC preview
      - Warning when no records selected
      - Progress bar after submitting items for modification

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:26 -03:00
63cfdf700b Bug 19806: Add classes to itemnotes in issues table
To test:
1 - Checkout an item with both public and non-public notes
2 - Note the notes display and both have circ-hlt class
3 - Apply patch
4 - Ensure display has not changed
5 - Note notes now have classes 'item-note-public' and
'item-note-nonpublic'
6 - Sign off

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:25 -03:00
405b0f14a4 Bug 19554: The inventory table should jump to detail instead of MARCdetail
This patch just replaces the link to detail.
Detail provides item information needed in case of inventory problems.

Test plan:
Go to Tools/Inventory.
Create an inventory list without barcode file.
Check if the link goes to detail now.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:25 -03:00
54d13ca4af Bug 19759: Make TestBuilder generates only 2 decimals for float
For instance items.replacementprice is decimal(8,2) but more than 2 decimals are generated.

It leads to issues when we compare expected objects:

    #          got: '135623.866142537'
    #     expected: '135623.87'

Test plan:
  prove t/db_dependent/TestBuilder.t
must return green

Signed-off-by: Dominic Pichette <dominic@inlibro.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Somehow I have the feeling that we should allow more decimals sometimes
and perhaps have a number of decimals parameter or so. Think of fields
like currency or discount.
But the current issues justify this change.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:25 -03:00
bdccbfcbab Bug 19706: (QA follow-up) Hide the collection code selector if no value is defined (for consistency)
Test plan:
0) Go to item search
1) Do have some authorized values in CCODE category -> selector of
collection is visible
2) Don't have any authorized value in CCODE category -> selector of
collection is not visible

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:25 -03:00
0c07f63e5f Bug 19706: Fix bad json formed when there are no CCODE values
To test:
1 - Delete all ccode values in your system
2 - Load the item search page
3 - View the console and note a js error
4 - Try to perform an item search to screen
5 - Internal server error ("unsupported format 'html'" in logs)
6 - Apply patch
7 - Reload page
8 - Note js error is gone
9 - Perform search to screen, success!

To test there is no regression:
1 - Have some values in CCODE authorised values
2 - Ensure collection drop down on item search displays correctly
3 - Ensure item search returns results ot screen with no js errors

Signed-off-by Owen Leonard <oleonard@myacpl.org>

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:25 -03:00
6d6c628d85 Bug 18330: (follow-up) Do not return undef explicitely
This patch fixes a perl critic issue, hopefully it will not break
something else.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-18 12:16:19 -03:00
e66a78d107 Bug 19767: Remove unused serial-issues.pl script
This patch removes three unused files:

serials/serial-issues.pl

...and its associated templates:

koha-tmpl/intranet-tmpl/prog/en/modules/serials/serial-issues-full.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serial-issues.tt

To test, apply the patch and search the Koha codebase for references to
any of those files. None should exist.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:39 -03:00
400804ada1 Bug 18330: (follow-up) Adapt holds.t to match the new datetime format
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:22 -03:00
Lari Taskula
54de74c6f6 Bug 18330: Handle date-time in Koha::Object->TO_JSON
This patch formats timestamps and datetimes to meet date-time definition
in RFC3339, as required by Swagger documentation.

Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:22 -03:00
Lari Taskula
cebadca9c3 Bug 18330: Add RFC3339 to Koha::DateUtils
To test:
1. prove t/DateUtils.t

Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:22 -03:00
cfb372c308 Bug 19663: Move JS to the footer: Reports
This patch modifies the staff client's reports templates so
that JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of
reports pages: All button controls, DataTables functionality, form
validation, etc.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Fix for QA: Remove unused Dopop function.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:22 -03:00
214cae8d3d Bug 19627: (follow-up) Include tools-menu.js on required templates
This follow-up adds tools-menu.js to the two patron clubs templates
which include the tools sidebar menu.

The patch also modifies tools-menu.js so that the correct sidebar link
is highlighted when editing or viewing club enrollments.

To test, apply the patch and view the patron clubs main page and the
patron clubs enrollments page. The sidebar menu should have the correct
link highlighted in both cases.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:14 -03:00
a52b0f596f Bug 19627: Move patron clubs templates JS to the footer
This patch modifies the staff client's patron clubs templates so that
JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of
each page: All button controls, DataTables functionality, tabs, etc.

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:14 -03:00
00cfd934c1 Bug 19607: Move admin templates JavaScript to the footer: Basic parameters
This patch modifies the staff client catalog-related administration
templates so that JavaScript is included in the footer instead of the
header.

To test, apply the patch and test the JavaScript-driven features of
each modified template: All button controls, DataTables functionality,
tabs, etc.

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>

Edit: Rebased on Bug 19560

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:14 -03:00
04d79ba063 Bug 19778: Move template JavaScript to the footer: Serials, part 4
This patch modifies more and more staff client serials templates so
that JavaScript is included in the footer instead of the header.

This patch adds a new JavaScript include, showpredictionpattern.js,
which is used by subscription-add.tt and subscription-numberpatterns.tt.
it also adds subscription-add.js, moving most of the JS embedded in
subscription-add.tt into an external file.

To test, apply the patch and test the JavaScript-driven features of the
modified templates: All button controls, DataTables functionality, tabs,
etc.

 - Serials -> New subscription
   - Date pickers
   - Popup search windows for vendors and bibliographic
     records
   - Next / Previous buttons
   - Form validation
   - Prediction pattern operations

   Test with new subscriptions, editing existing subscriptions, and
   duplicating subscriptions.

 - Serials -> Manage Numbering Patterns
   - Datatable
   - Delete confirmation
   -> Edit
      - Datepicker, test pattern
 - Serials -> Manage frequencies
   - Delete confirmation
   -> Edit
      - Form validation
 - Serials -> Subscription details -> Planning tab
   -> Edit history
      -> Datepicker
 - Serials -> Subscription details -> Renew
   - Datepicker

Signed-off-by: Dominic Pichette <dominic@inlibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:13 -03:00
666a1b2760 Bug 19777: Move template JavaScript to the footer: Serials, part 3
This patch modifies even more staff client serials templates so
that JavaScript is included in the footer instead of the header.

This patch adds a new JavaScript include, serials-toolbar.js, which is
required on pages which include serials-toolbar.inc.

To test, apply the patch and test the JavaScript-driven features of the
modified templates: All button controls, DataTables functionality, tabs,
etc.

 - Serials
   - Search for a subscription
     - Tabs, datatables, date pickers
     - Open a subscription for viewing
       - Tabs, toolbar buttons for delete, renew, and close.
   - Serial collection (in the sidebar menu)
     - Select all / clear all
     - Datatable
     - Print slip
     - Generate next

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:13 -03:00
512c5f0c0d Bug 19761: Move template JavaScript to the footer: Serials, part 2
This patch modifies more staff client serials templates so
that JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of the
modified templates: All button controls, DataTables functionality, tabs,
etc.

 - Serials -> Subscription detail -> Edit routing list
   - Add recipients
   - Save
     - "Save and preview routing slip" should trigger preview
       - In preview popup: Print and Close buttons should work correctly

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:13 -03:00
cc4cf2bde4 Bug 19758: Move template JavaScript to the footer: Serials, part 1
This patch modifies some staff client serials templates so
that JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of the
modified templates: All button controls, DataTables functionality, tabs,
etc.

- Serials -> New subscription
  - Search for a vendor
    - "Choose" link and "Cancel" button should work correctly
  - Search for record
    - "Choose" link and "Cancel" button should word correctly
- Serials -> Add subscription fields
  - Datatable, delete confirmation
  - Edit
    - Form validation (submit both authorised value and MARC field)
- Serials -> Check expiration
  - Date picker in search form
  - Search
    - Renew button triggers popup
- Serials -> Claims -> Search results
  - Date picker, datatable, form validation
  - Select all/none; Download claims

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:13 -03:00
6ea21c395a Bug 19514: Add client-side check
Signed-off-by: David Bourgault <david.bourgault@inlibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:58:13 -03:00
48bf229cc8 Bug 19514: Implement password restrictions into onboarding tool
Test plan:
1. Drop and recreate your database
2. Restart memcached
3. Go through the web installer
4. In the onboarding tool create a patron with a password of only 2 characters in length
5. Notice the patron is successfully created and no warning message is
displayed
6. Repeat step 1,2,3 and create a patron with a password of 3 characters
none of which are a uppercase letter or number and notice the patron is
successfully created and no warning message is displayed
7. Apply patch
8. Repeat steps 1,2,3 and create a patron with a password consisting of
2 characters, notice that after submitting the form the same form is
loaded again and there is a warning message at the top of the page
informing you the patron wasn't created
9. Repeat steps 1,2,3 and create a patron with a password consisting of
3 characters (all lower case) and submit the form, notice the same form
is reloaded and a warning message at the top of the page informs you
that the patron wasn't created because the password was weak
10. Repeat steps 1,2,3 and create a patron with a password consisting of
3 characters (one lower case letter, one upper case letter and one
number) and submit the form and notice this time the next form in the onboarding is displayed with the message at the top of the screen informing you that the patron was successfully created

Sponsored-By: Catalyst IT

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:57:56 -03:00
e224182cc3 Bug 19560: Correctly escape branchcode in admin/branches.pl
Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:57:56 -03:00
441585a6cc Bug 19776: (follow-up) remove dup category_type keys
The previous patch was obviously wrong, the category_type key appeared
twice.
categories.category_type is a varchar(1) and 'P' is not 'X'.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-14 16:10:15 -03:00
233b83ca5d Bug 19410: (follow-up) Move build_query_params_from_api into a helper
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
ec9f747913 Bug 19410: (follow-up) Add reserved params definitions
This patch re-adds some parameters I left out during some rebasing tasks
and ended up on a separate patchset (bug 18731).

The introduced parameters definitions are only used on endpoint definitions
that implement (at least) pagination. No need to test them here but easier
adding them here than on a patch implementing a new enpoint, which would become
a dependency for other endpoints.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
f1163dba9d Bug 19410: Move build_query_params_from_api into a helper
This patch creates the 'build_query_params' helper, instead of the
original function in Koha::Objects.

Unit tests are removed for Koha::Objects::_build_query_params_from_api and
written for the helper plugin.

The objects.search helper gets a call to build_query_params added. Tests for it
updated to match this behaviour change.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/Koha/REST/Plugin/Query.t \
          t/db_dependent/Koha/Objects.t \
          t/db_dependent/Koha/REST/Plugin/Objects.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
Julian Maurice
86706c3b34 Bug 19410: Move search_for_api into a Mojo helper
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
Lari Taskula
9f5b10126d Bug 19410: (follow-up) Fix typo in POD
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
dda7b2ce4d Bug 19410: Unit tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
7805ef2c01 Bug 19410: Add Koha::Objects->search_for_api
Following the discussion about the best way to make things simpler for
developing the REST api, I quote Lari's email:

"As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects?
so instead we could have something like (ignore my bad choice of naming)...:
sub list_vendors {
  my $c = shift->openapi->valid_input or return;
  my $args = $c->validation->output;
  my $vendors;

  return try {
    $vendors = Koha::Acquisition::Booksellers->api_list_search($c);
    return $c->render(status => 200, openapi => $vendors);
  } catch {
    ...
  }
}"

We all agreed we neeed something like that. Here's a possible implementation. I take
advantage of the previously written Mojo helpers, that are fully covered by tests.

I submit this early so anyone can take a look and gather ideas to make it even better.
I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing
on bug 18731.

Thanks!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
8430a541af Bug 19370: (QA follow-up) Use OpenAPI's handling of pipe separated values
This patch makes the helper handling _order_by params expect a list of
values instead of a (to-be-splitted) string.

The idea is that the OpenAPI plugin will take care of splitting
pipe-delimited values if the spec is correctly defined.

Note: In the process I noticed + on the URL represents a space, so the
helper function is updated to handle both + and %2B as ascending.

To test:
- Run:
  $ kshell
 k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass!
- Sign off :-D

Edit: Removed rebasing leftover making the tests fail.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
2548836089 Bug 19370: Remove undefined variable warning
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
5a31321676 Bug 19370: Add helper function for order_by attribute generation
This patch introduces a helper function called 'dbic_merge_sorting'
to Koha::REST::Plugin::Query.

This simple function adds SQL::Abstract order_by attribute to the passed
$filter hashref, as explained in the POD.

It introduces a syntax for passing sorting params on the request to the REST api.
The proposed syntax has been found in the wild, and is pretty trivial to parse/work with:

    GET /api/v1/<endpoint>?order_by=+column_1|-column_2|column_3

As explained on the POD, + stands for 'asc' and - for 'desc'. If ommited, it defaults to the
DB engine default (usually asc).

To test:
- Apply this patches
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass! And they make sense! :-P
- Sign off :-D

Edit: renamed params to match DBIC terminology. My bad :-D (tcohen)

Sponsored-by: Camden County

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
2485afc57c Bug 19370: Unit tests
Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
4b07ae3f41 Bug 19278: DBRev 17.12.00.004
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
296442d2d5 Bug 19278: Mention RESTdefaultPageSize in POD
This patch adds information about RESTdefaultPageSize usage
when the per_page parameter is absent on the query.

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
96f442badd Bug 19278: (follow-up) Make the pagination plugin use RESTdefaultPageSize
Use 20 as default for RESTdefaultPageSize (just in case)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
54880b1a4e Bug 19278: Make the pagination plugin use RESTdefaultPageSize
This bug introduces a new syspref RESTdefaultPageSize that is used on
the Koha::REST::Plugin::Pagination plugin to default to a valid value
for the page size if the param is not present on the query.

This patch also considers the situation in which no 'page' param is
passed, and no header should be added.

To test:
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/Koha/REST/Plugin/Pagination.t
=> FAIL: Tests fail because the plugin doesn't behave as the tests
expect.
- Apply this patch
- Run:
 k$ prove t/Koha/REST/Plugin/Pagination.t
=> SUCCESS: Tests pass!
- Sign off :-D

Sponsored-by: Camden County
Sponsored-by: ByWater Solutions

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
a7d333f3cd Bug 19278: Unit tests
This patch introduces tests for a behaviour change in
Koha::REST::Plugin::Pagination.

To test:
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/Koha/REST/Plugin/Pagination.t
=> FAIL: Tests should fail without the followup patch applied

Sponsored-by: Camden County
Sponsored-by: Bywater Solutions

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
5fd7834394 Bug 19278: Add RESTdefaultPageSize syspref
Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
538536da73 Bug 19369: Add helper function for pagination attributes generation
This patch introduces a new helper function to the Koha::REST::Plugin::Pagination
plugin, called 'dbic_merge_pagination'.

This simple function adds SQL::Abstract pagination attributes ('page' and 'rows') to the
passed $filter hashref.

To test:
- Apply this patches
- Run:
  $ koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/Koha/REST/Plugin/Pagination.t
=> SUCCESS: Tests pass!
- Sign off :-D

Sponsored-by: Camden County

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00
83ca8fb600 Bug 19369: Unit tests
Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-11 17:46:59 -03:00