Commit graph

43934 commits

Author SHA1 Message Date
efce19392f Bug 29491: Improve display of notices in patron details
This patch updates the patron notices list so that notices are shown in
a modal dialog instead of inline in the table. The "Resend" button is
shown in the modal window controls.

To test, apply the patch and locate a patron in the staff interface with
multiple sent notices.

- View the patron's "Notices" tab.
- In the table of notices, click one of the notice titles.
- A modal window should appear with the notice subject as the header
  and the notice content in the main body of the modal.
  - If the message has any other status than 'pending' there should be a
    "Resend" button in the modal footer. Confirm that it submits the
    form and resends the correct message.
  - Try viewing multiple notices to confirm that the contents of the
    modal are correctly updated for each message.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-13 16:37:32 -10:00
2abdce7c94 Bug 29491: (preparatory step) Reindent template
Step 1: Replace tabs with spaces and reindent. This patch should include
only whitespace changes. If you view the diff while ignoring whitespace
there should be no changes.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-13 16:37:32 -10:00
Florian Bontemps
80c3c91882 Bug 24866: Changed $raw for html for extra safety
Same test plan as before

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-12 21:26:26 -10:00
Florian Bontemps
95186ffd0c Bug 24866: (follow-up) Replaced tabulations by dashes
The rendering of SELECT elements is up to the browser.
But Bug 16123 CSS code 'style="padding-left: xx' doesn't work on modern browsers.

Based on the previous contribution, this fix replaces CSS style attribute with dashes, creating a leveled structure that should work with most browsers.

Tested on Linux Ubuntu with Firefox 94.0, Chromium 95.0.4 and Opera 81.0.1
TEST PLAN :

1. Go to the Administration module
2. Add a new budget (ie : Budget 2022)
3. Add a fund to this budget (ie : Book)
4. Add a sub-fund to fund Book (ie : Fiction)
5. Add another sub-fund, this time to sub-fund Book (ie : Adult fiction)
You will have this hierarchy :

Budget 2022
 |____ Book
         |_____ Fiction
                |_____ Adult fiction

6. Go to the Acquisition module
7. Select a vendor and create a new basket
8. Place an order
9. Check the budget dropdown menu

BEFORE PATCH
Book
Fiction
Adult fiction

OR

Book
   Fiction
         Adult fiction

AFTER PATCH
Book
 -- Fiction
 -- -- Adult fiction

 Co-authored-by: Didier Gautheron <didier.gautheron@biblibre.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-12 21:26:26 -10:00
Didier Gautheron
3487877f56 Bug 24866: Display budget hierarchy in the budget dropdown menu used when placing a new order
The rendering of SELECT elements is up to the browser.
But Bug 16123 CSS code 'style="padding-left: xx' doesn't work on modern browsers.

This patch replace CSS style attribute with &emsp; html entity.

On supported platforms
TEST PLAN :

1. Go to the Administration module
2. Add a new budget (ie : Budget 2020)
3. Add a fund to this budget (ie : Book)
4. Add a sub-fund to fund Book (ie : Adult fiction)

You will have this hierarchy :

Budget 2020
 |____ Book
         |_____ Adult fiction

5. Go to the Acquisition module
6. Select a vendor and create a new basket
7. Place an order
8. Check the budget dropdown menu

BEFORE PATCH
Book
Adult fiction

OR

Book
   Adult fiction

AFTER PATCH
Book
   Adult fiction

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-12 21:26:26 -10:00
fccf143330 Bug 29685: Reduce item processing by calculating 'items any available' outside of loop
See bug 24185, this avoids looping every each item of the record for every item of the record

How to reproduce:

1) on freshly installed kohadevbox create/import one book,
remember that biblionumber for later use it in down below,

2) add 100 items for that book for some library,

3) find some patron, that patron's card number we will
use as a borrower down below to open holds page,

4) check for the rule or set up a single circulation rule
in admin "/cgi-bin/koha/admin/smart-rules.pl",
that rule should match above book items/library/patron,
check that rule to have a non-zero number of holds (total, daily, count) allowed,
and, IMPORTANT: set up "On shelf holds allowed" to "If all unavailable",
("item level holds" doesn't matter).

5) open "Home > Catalog > THAT_BOOK > Place a hold on THAT_BOOK" page
("holds" tab), and enter patron code in the search field,
or you can create a direct link by yourself, for example, in my case it was:
/cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=23529000686353

6) it should be pretty long page generation time on old code, densely increasing for every hundred items added. In the case of this solution, it's fast, and time increases a little only, linear.

In testing with 100 books I went from ~6.5 seconds to ~3.2 seconds

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-12 21:26:26 -10:00
cd0d647c61 Bug 29856: Make the ES config more flexible
I need to add a 'request_timeout' entry to the ES configuration to fix some timeout problems on the sandboxes.

Instead of hard coding this new option it seems preferable to be
flexible and allow different options to be passed from the config file.

Test plan:
Add to the $KOHA_CONF, inside the elasticsearch section
  <request_timeout>60</request_timeout>
Rebuild the ES index
  koha-elasticsearch --rebuild kohadev
Change the value of the timeout to 1
Rebuild the index
It should fail (with a quite bad error 'Bad response received when
submitting request to Elasticsearch')

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-12 21:26:26 -10:00
9f8c77e864 Bug 29788: Fix t/db_dependent/Reserves.t
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 20:30:26 -10:00
42491ed1c3 Bug 29557: DBRev 21.12.00.006
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
Katrin Fischer
f2389de803 Bug 29557: (QA follow-up) Add note for translated notices to update statement
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
9c10d75443 Bug 29557: Add auto_account_expired to AUTO_RENEWALS
It was missing and the notice sent was not providing the reason of the
failure.

Test plan:
Check an item out with a date in the past, mark it as auto renew
Modify the expired date of the patron and set it in the past
Run the automatic_renewals.pl cronjob script, confirm that the notice
now contains the reason of the failure.

QA note: The template will be updated only for English installations.
Should we add an alert for others?

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
Florian Bontemps
f004ad000d Bug 17127: Remove notes from detail.tt to only use MARCNOTES
Notes come from the biblio table, but that table is already used to fill in MARCNOTES through Biblio.pm and get_marc_notes.
Get_marc_notes does check for NotesToHide and already read every note on the records, but .notes doesn't go through that same filter.
I don't see the point of keeping notes as a condition when MARCNOTES does the same job but better.

To test:
    1) Take any record, or create one
    2) Input something in the 500 field (or 300 in UNIMARC)
    3) In Systempreferences -> NotesToHide, fill in the number 500 (or 300).
    4) Save, then go look at the record detail in the OPAC and admin website.
    5) You should still see the 500 or 300 field under the Description tab.
    6) Apply patch.
    7) Reload the record detail page.
    8) Observe the error is gone.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
c780d61f90 Bug 29419: Retain user's inputs when suggesting for purchase and match found
If a user suggests for purchase and a match is found, their inputs was
not retained: quantity, item type, library, reason.

Test plan:
1. Suggest for purchase
2. Fill the title in with a string that will match an existing record
3. Fill value in quantity, item type, library and reason input/dropdown
4. Submit
=> Notice that with this patch the values you entered are retained on
the confirmation screen

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
1824b761a8 Bug 29688: Incorrect use of _() in holds.js
Bug 29404 moved code from request.tt into holds.js, and I didn't know
about the _() vs. __().

This patch fixes that.

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
06f1a24297 Bug 29788: Fix batch delete item
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
21bc236e57 Bug 29788: Make Koha::Item->safe_to_delete use Koha::Result::Boolean
This patch reuse the (awesome) Koha::Result::Boolean module to retrieve
the return of Koha::Item->safe_to_delete.

Test plan:
Try to delete an item that has previously been checked out and confirm
that you are still blocked.
Try using the cronjobs, the item and biblio detail pages, as well as the
batch delete item tool.

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
381898d8ca Bug 29790: Restore warning if deletion of serial item fails
If the deletion of a serial item failed, the UI did not provide a warning/error message.

Test plan:
0. Create a new subscription with "Create an item record when receiving
this serial"
1. Receive a new item, set a barcode
2. Check it out
3. Select the item you have received in the serial item list (page
"Serial collection information") and click "Delete selected issues"
4. Tick "Delete the associated items" and confirm the deletion
=> Without this patch the deletion fail but the UI does not warn it
=> With this patch applied you see a warning "one or more associated
items could not be deleted at this time."

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
d85328ee3c Bug 29789: Remove unused $error from cataloguing/additem.pl
my $error        = $input->param('error');

It should be removed as $error is used later but not related to this variable.

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-11 12:38:35 -10:00
c56b74ae9c Bug 29553: (QA follow-up) Check defined instead of evaluating as boolean
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
f9fc43eb6f Bug 29553: Regression tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
0195da0a8a Bug 29553: Fix crash on undefined notforloan value
Test plan:
Set item level itypes to biblioitems.
Find a record with itemtype NULL, having an item.
Place a hold. Without this patch, it crashes.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: ThibaudGLT <thibaud.guillot@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
4b3b6f1996 Bug 29391: Improve output of reservoir search
This patch makes the cataloging reservoir search results a configurable
DataTable. The empty edition and date columns are removed, and an import
data column is added.

To test, apply the patch and go to Cataloging.

- Perform a cataloging search which will return results from the
  reservoir.
- The table of reservoir search results should be a DataTable with
  paging, navigation, filtering, column configuration, etc.
  - Confirm that all DataTable controls work correctly.
- Go to Administration -> Table settings -> Cataloging -> addbooks.
  - Try modifying the default configuration and confirm that the
    settings take effect.

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
e2e2e4bed2 Bug 29778: DBREv 21.12.00.005
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
c2e91f7248 Bug 29778: Remove DBMS error
ERROR - {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Table 'additional_contents' is specified twice, both as a target for 'DELETE' and as a separate source for data at /kohadevbox/koha/C4/Installer.pm line 738

Happened on MariaDB 10.1 and 10.3, not 10.6

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
0c4590160a Bug 29778: Prevent orphan additional contents
When deleting a content, only the main one (lang="default") is removed,
which leads to orphan contents in the DB that are still displayed on the
UI.

Test plan:
0. Don't apply this patch
1. Create some contents, translate them in different languages
2. Delete some of them
=> Note that they are still displayed on the UI and that the entries
with lang!="default" are still in the DB
3. Apply this patch
4. Repeat 1
5. Run updatedatabase
6. Delete from of the contents
=> Note that the orphan entries created before you applied the patch
have been removed and that the "delete" behaviour is now working
correnctly.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
cb6ef3ac19 Bug 29737: Remove some unecessary parameters
We don't need them. We could also remove the biblionumber but it
requires change to the controller I'd prefer to not do now.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
fd1b110fd5 Bug 29737: Fix suspend from hold list
From holds list of a bibliographic record, the "unsuspend" button does not work as expected.
The form is submitted but the suspension is still there.

There are 3 requests, 2 GET and 1 POST.
One of the GET is rejected by Firefox (NS_BINDING_ABORTED)

Test plan:
Place some items on hold, play with suspend/unsuspend from the hold list
/cgi-bin/koha/reserve/request.pl?biblionumber=XX

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
e4f4a7ea98 Bug 29794: (follow-up) Add license
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
db5c5c0bc7 Bug 29794: Add missing include in delete_items.pl
This patch adds a missing include so the script is no longer broken.

To test:
1. Choose an item that is checked out and copy its barcode
2. Run:
   $ kshell
  k$ perl misc/cronjobs/delete_items.pl --verbose \
          --where "barcode='39999000010831'"
=> FAIL: It explodes with:
Can't locate object method "find" via package "Koha::Items"...
3. Apply this patch
4. Repeat 2
=> SUCCESS: You get:
Where statement:  where barcode='39999000010831'
Item '549' not deleted: book_on_loan
5. Sign off :-D

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
60f6fe17f4 Bug 29747: Delete columns that don't exist from settings
This patch simply checks if we are callinmg from the plugin, and removes
two columns from the settings if so

To test:
 1 - In Admin->Marc bibliographic framework got to Marc Structure for default framework
 2 - Search for 856$u
 3 - Set Plugin to upload.pl
 4 - Edit a record in the default framework
 5 - Under 856u, click 'Upload'
 6 - Uplaod a file and then click 'Choose'
 7 - nothing happens
 8 - View consiole (f12) and see error
 9 - Apply patch
10 - Reload the page
11 - No more error
12 - Click choose
13 - Record link is populated

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
3eb7480e0c Bug 26296: DBrev 21.12.00.004
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
432f296b96 Bug 26296: (follow-up) Make sure title remains mandatory
This patch adds a flag to the OPAC preferences file marking suggestion
title as mandatory OPACSuggestionMandatoryFields and excluded from
OPACSuggestionUnwantedFields.

The patch also modifies the markup around required fields in the OPAC
suggestion form to comply with changes made in Bug 27668 to mandatory
field styling.

To test, apply the patch and restart services.

- Test the OPACSuggestionMandatoryFields preference. In the modal,
  "title" should be checked and the label in red. It should not be
  possible to uncheck the checkbox.
  - Test that the "Select all" and "Clear all" links don't affect the
    "title" checkbox.
  - Confirm that your selections are still saved correctly.
- Test the OPACSuggestionUnwantedFields preference. In the modal,
  "title" should be unchecked and disabled.
  - Test that the "Select all" and "Clear all" links don't affect the
    "title" checkbox.
  - Confirm that your selections are saved correctly.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
fe46f077a7 Bug 26296: Use new table column selection modal for OPAC suggestion fields
This patch builds on the change introduced by Bug 22844, changing the
selection mode for the OPACSuggestionMandatoryFields and
OPACSuggestionUnwantedFields preferences to a modal.

This patch includes a database update for converting the format of the
saved values in these preferences. Previously the suggestions table
fields would be separated by a comma. Now they should be separated by a
pipe.

To test, apply the patch run the database update.

 - Go to Administration -> System preferences.
 - Search for 'OPACSuggestion.'
 - The input fields for OPACSuggestionUnwantedFields and
   OPACSuggestionMandatoryFields should appear as "locked" (read-only)
   inputs.
 - Clicking either input field should trigger a modal window with
   checkboxes for each available column in the suggestions table.
 - Test that the "select all" and "clear all" links work correctly.
 - Test that the "cancel" link closes the modal without saving your
   selections.
 - Test that the "Save" button closes the modal, copies your
   selections to the form field, and triggers the preference-saving
   function.
 - Test that changes to both preferences are correctly reflected in the
   OPAC suggestion form.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-09 21:04:17 -10:00
895fc88605 Bug 29508: Make GET /patrons/:patron_id use Koha::Patrons->search_limited
This patch makes the route return 404 if the user is not allowed to see
the requested patron information.

To test:
1. Apply the regression tests
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons.t
=> FAIL: The code doesn't respect limits
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
d46debdff2 Bug 29508: Regression tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
c9cb8e5879 Bug 29506: (follow-up) Adapt GET /patrons
This patch makes GET /patrons rely on this new behavior from the
objects.search helper.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests still pass!
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
13fba03080 Bug 29506: Make objects.search call search_limited if present
This patch makes objects.search implicitly update the passed
*$result_set* to use search_limited. This way no object leaks could
happen without noticing.

To test:
1. Apply the regression tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t
=> FAIL: Tests fail because search_limited is not used
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! Results are correctly filtered based on userenv!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
91123608b2 Bug 29506: Regression tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
152bc1f04e Bug 29503: Make GET /patrons use Koha::Patrons->search_limited
This patch makes the controller method use Koha::Patrons->search_limited
so filters based on configuration and permissions apply when fetching
patrons.

To test:
1. Apply the regression tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons.t
=> FAIL: Boo, you get more patrons than you should
3. Apply the patch
4. Repeat 2
=> SUCCESS: Yay! Things are filtered as expected (i.e. using
Koha::Patron->libraries_where_can_see_patrons)
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
2b432cec1d Bug 29503: Regression tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 14:03:28 -10:00
724f53e5ec Bug 29680: Change markup to correct button radius
This patch alters the markup around the "Show SQL/Hide SQL" buttons so
that they are not styled as if they are a button group.

To test, apply the patch and run an SQL report.

The "Show SQL code" button should be styled consistently with other
single buttons in the toolbar. Click it to test that the "Hide SQL code"
button is also correct.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Andreas Roussos <a.roussos@dataly.gr>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:49:09 -10:00
cf86a5554d Bug 29772: (follow-up) Document error codes
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
82c32a1aa5 Bug 29772: Make DELETE /patrons/:patron_id return error codes
This patch makes the controller add the error_code attribute on error
conditions payload.

To test:
1. Apply the regression tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons.t
=> FAIL: Boo, the API doesn't include the error_code attribute on the
error responses for the DELETE /patrons/:patron_id route
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! error_code is included in the response!
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
b3fe6a4ba3 Bug 29772: Regression tests
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
770e263b87 Bug 29765: Adjust DELETE /patrons/:patron_id controller
This patch adjusts the only current place using the
Koha::Patron->safe_to_delete method to the new return value. There
should be no behavior change

To test:
1. Apply the previous patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons.t
=> FAIL: Tests fail, because of the change, the controller is broken
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! No test tweak required, no behavior change
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
ed2acc9266 Bug 29765: Make Koha::Patron->safe_to_delete use Koha::Result::Boolean
This patch makes the safe_to_delete method in Koha::Patron return this
new object type instead of a plain string. This way we have a consistent
way to deal with 'can_*'-like methods return values when feedback is
needed.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patron.t
=> SUCCESS: The adjusted tests pass. Tests cover the boolean context
eval and also the carried messages, that include the same string code
that was returned originally.
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
367a90ca18 Bug 29746: (it-doesn't-hurt follow-up) More tests
In an attempt to add (even) more tests for this library, we wanted to
add tests for the return values initialization and then hit
a wall when trying to add tests: Test::More tries to compare in string
context first [1], and when you force integer context (by using cmp_ok +
'==') it tells '==' is not overridden for the class.

So this patch adds those tests, and also the overloaded '==' operator
that is required for such tests.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Result/Boolean.t
=> SUCCESS: Tests pass
3. Sign off :-D

[1] https://metacpan.org/pod/Test::More#Overloaded-objects

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
a8ab17f823 Bug 29746: Add Koha::Result::Boolean
This patch introduces a new OO class that can be used as return value
from methods that need to return boolean values, but also provide some
feedback. This last bit is implemented using Koha::Object::Message
objects that can carry valuable information.

This class can also implement a `to_api()` method so it is suitable for
API usage. And so the Koha::Object::Message class. Will be done as
needed.

If some other result types are required, then we can move some of the
messaging logic to a top-level Koha::Result class this one inherits from
(and the new one as well, say, Integer?).

To test:
1. Apply this patchset
2. Run:
   $ kshell
  k$ prove t/Koha/Result/Boolean.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
01a38cfebd Bug 29746: Unit tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00
dbd69d6650 Bug 29741: (follow-up) Make DELETE /patrons use the new validation method
This patch adapts the route so it uses the newly introduced
Koha::Patron->safe_to_delete method.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/patrons.t
=> SUCCESS: Tests pass
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests still pass!
4. Sign off :-D

Note: There's a trivial behavior change, in which the 'anonymous patron'
use case is caugh eariler than the ->delete call. I left the exception
catch block just in case, who knows :-D

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

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-05 13:33:46 -10:00