https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16631

--- Comment #159 from Casey Conlin - mattermost @Casey246 
<[email protected]> ---
Created attachment 199520
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199520&action=edit
Bug 16631: Institute library limits

This patch implements the library_limit concept for Report/Reports. Staff with
the correct permission and superlibrarians can set libaries to which the report
should be visible, if the system preference is enabled.

Test plan:
Confirm Initial Settings
1. Log in to Koha staff with username: koha and password: koha and set your
library as Centerville if it's not already.
2. Visit the Saved reports page, and create and save three reports: Report 1,
Report 2, and Report 3. The SQL query for each report doesn't matter, it should
just be something valid.
3. Visit the Patrons page and create two staff users: StaffReportLimitUser and
StaffNoLimitPermission. Set their home libraries to Centerville and Fairfield,
respectively.
4. Under Allow access to the reports module, ensure both users have report
management permissions for Create, Delete, Execute.

Verify Patch Settings
5. Apply the patch and restart services. If using Koha Testing Docker (KTD):
from the Koha repo directory, apply the patch (e.g. `git bz apply 16631`, or
check out the patched branch with `git fetch && git checkout <branch>`), then
run `ktd --shell` to enter the KTD shell and run `restart_all`. If the patched
branch is already checked out, just enter the KTD shell and run `restart_all`.
6. Click Patrons in the top navbar to go to the Patrons page.
7. Search for "StaffReportLimitUser" in the patron search field.
8. Click StaffReportLimitUser to edit the patron record for this user.
9. Click More -> Set permissions to access the permissions screens for the
StaffReportLimitUser.
10. In the row for Allow access to the reports module (reports), click Show
details to view relevant permissions.
11. Confirm Manage Report Limits (manage_report_limits) is an option under
Allow access to the reports module (reports).
12. Click the checkbox for Manage Report Limits to give this user this
permission, and click Save.
13. Go to the System Preferences page (Click the More dropdown from the top nav
bar, click Administration, click System Preferences).
14. Verify Reports is an option in the left side navigation bar, and that when
clicked, you see the LimitReportsByBranch option.
15. Enable LimitReportsByBranch as described in step 14.
16. Go back to Saved reports as in Step 2.
17. Click Edit in the row menu for Report 1.
18. At the bottom of the Report 1 edit page, you should see a Library
limitation select box.

Verify the Library Limitation Settings are Persisted
19. Choose Centerville from the select box and click Update SQL.
20. Reload the page, or navigate away from the page and go back to the edit
screen for Report 1.
21. Verify that Centerville is still in the Library limitation select box.
22. Add Fairfield in the Library limitation select box and click Update and run
SQL.
23. Go back to editing Report 1.
24. Confirm the Library limitation select box has both Centerville and
Fairfield selected.
25. Duplicate Report 1.
26. Confirm the Library limitation select box has both Centerville and
Fairfield selected.
27. Click Save Report.
28. Confirm the Library limitation select box has both Centerville and
Fairfield selected.

Verify Reports are Limited Based on Library Limitations
29. Edit Report 1 to add Centerville in the Library limitation select box as
the only choice and click Update SQL.
30. Edit Report 2 to add Fairfield in the Library limitation select box as the
only choice and click Update SQL.
31. Report 3 should have no library limitations, so it should be visible to all
libraries.
32. Go to Saved reports as in Step 2.
33. Confirm you do not see Report 2, and only Report 1 and Report 3.
34. In the upper right corner, click the drop down that says koha Centerville
and click Set library to change your library.
35. Set your library to Fairfield.
36. Go to Saved reports as in Step 2.
37. Confirm you do not see Report 1, and only Report 2 and Report 3.

Verify Disabling LimitReportsByBranch Preference Shows All Reports
38. Disable LimitReportsByBranch preference as in steps 13 to 15.
39. Go to Saved reports as in Step 2.
40. Confirm Report 1, Report 2, Report 3 are visible.
41. Click to edit Report 1 and verify there is no Library limitation select
box.

Verify Library limitations are Persisted When EnableFilteringReports is Toggled
On or Off
42. Enable LimitReportsByBranch preference as in steps 13 to 15.
43. Ensure your library is set to Fairfield as in step 35.
44. Go to Saved reports as in Step 2.
45. Confirm Report 1 is not visible, and Report 2 and Report 3 are visible.
46. Click to edit Report 2 and verify the Library limitation select box is at
the bottom of the page and that it has Fairfield selected.

Verify the Show all reports option shows all reports for users with the Manage
Report Limits permission and superlibrarians
47. Go to Saved reports as in Step 2 and in the Show reports dropdown, select
Show all reports, and click Apply filter.
48. Confirm the page reloads with all reports visible: Report 1, Report 2, and
Report 3 should be visible.
49. Select Show my branch reports from the dropdown and click Apply filter.
50. Confirm Report 1 is not visible, and Report 2 and Report 3 are visible (you
should only see reports for your branch, Fairfield).

Verify Report filters return the correct results
51. Go to Saved reports as in Step 2.
52. Verify you're viewing only your branch's reports in the filter.
53. Under Filter in the left sidebar, type "2" in the Keyword field and click
Apply filter.
54. Confirm only Report 2 is visible.
55. Under Filter in the left sidebar, type "1" in the Keyword field and click
Apply filter.
56. Confirm there are no reports visible, and the message "No saved reports
match your criteria" is displayed.

Verify Library Limits column is available to superlibrarians and users with the
Manage Report Limits permission
57. Go to Saved reports as in Step 2.
58. Click the Columns dropdown and ensure that the Library limits column is
available to select for display. Select it.
59. Confirm that the Library limits column is now visible in the list of
reports and that it shows the correct library limitations for each report
(e.g., Report 1 should show 1 library limitation and Centerville (CPL) on
hover, Report 2 should show 1 library limitation and Fairfield (FFL) on hover,
and Report 3 should show no limitation).

Verify the Show all reports and Limit reports options are available to users
that are not superlibrarian but have the Manage Report Limits permission
60. For the StaffReportLimitUser, add the permission for Manage Report Limits
as described in steps 9 to 12. This will allow this user to see the Show all
reports and Limit reports options.
61. Log out of the koha admin account. In the upper right corner, click the
drop down that says koha Fairfield and click Log out.
62. Log in as StaffReportLimitUser, the previously created staff user with
report permissions.
63. Confirm the staff user's library is Centerville in the upper right corner
of the screen.
64. Go to Saved reports as in Step 2.
65. Confirm the filter option for Show reports is visible.
66. Click to edit Report 1.
67. Verify there is a Library limitation select box and that it can be
interacted with.

Verify the Show all reports and Limit reports options are not available to
users that are not superlibrarian and do not have the Manage Report Limits
permission
68. Log out of the StaffReportLimitUser account.
69. Log in as StaffNoLimitPermission, the previously created staff user without
the Manage Report Limits permission.
70. Confirm the staff user's library is Fairfield in the upper right corner of
the screen.
71. Go to Saved reports as in Step 2.
72. Click the Columns dropdown and ensure that the Library limits column is not
in the list of available columns to select for display.
73. Confirm the filter option for Show reports is not available.
74. Click to edit Report 2.
75. Verify there is no Library limitation select box at the bottom of the page.

[NEW] Verify library limits are auto-assigned and preserved correctly for
non-permissioned users
76. Still logged in as StaffNoLimitPermission (Fairfield) from the previous
section. Go to Saved reports and click New report. Enter "Limit Auto-Assign
Test" as the report name and SELECT 1 as the SQL. Confirm there is no Library
limitations select box visible on the form. Click Save.
77. Go back to Saved reports. Click Edit for Report 2 (limited to Fairfield).
Add `-- test` as a trailing SQL comment and click Update SQL. This simulates a
non-permissioned user saving an existing report that already has limits.
78. Go back to Saved reports. Click Edit for Report 3 (no library limits). Add
`-- test` as a trailing SQL comment and click Update SQL. This simulates a
non-permissioned user saving an existing report that has no limits.
79. Log out and log back in as StaffReportLimitUser (Centerville, has
manage_report_limits).
80. Go to Saved reports. Use Show all reports if needed. Find "Limit
Auto-Assign Test" and click Edit. Confirm the Library limitations select box
shows Fairfield as the only selected library — the report was automatically
limited to the creator's home library on create.
81. Find Report 2 and click Edit. Confirm the Library limitations select box
still shows only Fairfield — the existing limit was preserved when the
non-permissioned user saved the report.
82. Find Report 3 and click Edit. Confirm the Library limitations select box is
empty — no limits were introduced when the non-permissioned user saved a report
that had no existing limits.

Verify limited reports are not visible to users without permissions
83. While still logged in as StaffReportLimitUser from step 79, copy the URL
for the edit page of Report 1.
84. Log out of the StaffReportLimitUser account.
85. Log in as StaffNoLimitPermission, the user without the Manage Report Limits
permission.
86. Paste the copied URL for the edit page of Report 1 into the browser and
navigate to it.
87. Confirm that you see an error message that says "This report is restricted
and cannot be accessed by the current user." and that the page does not load
the report details.

Run Unit Tests
88. Using Koha Testing Docker, in the Koha home directory run the command: ktd
--shell to start the ktd shell.
89. Run command: reset_all to drop and recreate the koha database.
90. Run command prove t/db_dependent/Koha/Reports.t to run the test.
91. This file contains the unit tests for the reports_branches table and the
new subtest `library limits enforcement on save and update`, which covers
auto-assignment of branch limits on create and preservation of limits on update
for non-permissioned users.
92. All tests should pass.
93. Run command prove t/Koha/Auth/Permissions.t
94. Permissions unit tests in this file were updated.
95. All tests should pass.
96. Run command prove t/db_dependent/Reports/Guided.t
97. The Guided report tests were updated to account for the new library
limitations and permissions.
98. All tests should pass.

Signoff
99. Sign off if the steps above check out.

Sponsored-by: Ramapo Catskill Library System
Co-authored-by: Casey Conlin <[email protected]>
Signed-off-by: Emmi Takkinen <[email protected]>
Signed-off-by: Andrew Fuerste Henry <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to