Bug 30418

Summary: Add permission and setting for public lists to allow staff with permission to edit contents
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: ListsAssignee: Alex Buckley <alexbuckley>
Status: CLOSED FIXED QA Contact: Kyle M Hall (khall) <kyle>
Severity: enhancement    
Priority: P5 - low CC: alexbuckley, caroline.cyr-la-rose, hammat.wele, jonathan.druart, kyle, lucas, m.de.rooy, martin.renvoize, matt.blenkinsop, sally.healey
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33722
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Caroline Cyr La Rose Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/691
Text to go in the release notes:
Add a new 'Permitted staff only' option to public lists, allowing only permitted staff users to manage the list contents from the staff client and OPAC. The 'Permitted staff only' option differs from the 'Staff only' option because permitted staff are Koha patrons with the 'catalogue' permission enabled and the new 'edit_public_list_contents' sub-permission enabled.
Version(s) released in:
23.05.00
Circulation function:
Bug Depends on: 26346    
Bug Blocks: 13888    
Attachments: Bug 30418: Database changes
Bug 30418: Updated schema file
Bug 30418: Template and JavaScript changes
Bug 30418: Add ability for permitted staff to edit list contents
Bug 30418: Unit tests
Bug 30418: Re-order options of who can edit list contents
Bug 30418: Database changes
Bug 30418: Updated schema file
Bug 30418: Template and JavaScript changes
Bug 30418: Add ability for permitted staff to edit list contents
Bug 30418: Unit tests
Bug 30418: Re-order options of who can edit list contents
Bug 30418: Database changes
Bug 30418: Updated schema file
Bug 30418: Template and JavaScript changes
Bug 30418: Add ability for permitted staff to edit list contents
Bug 30418: Unit tests
Bug 30418: Re-order options of who can edit list contents
Bug 30418: (follow-up) Fixes for QA test tools
Bug 30418: Database changes
Bug 30418: Updated schema file
Bug 30418: Template and JavaScript changes
Bug 30418: Add ability for permitted staff to edit list contents
Bug 30418: Unit tests
Bug 30418: Re-order options of who can edit list contents
Bug 30418: (follow-up) Fixes for QA test tools
Bug 30418: (QA follow-up): Fix unit test count
Bug 30418: Fix t/Koha/Auth/Permissions.t

Description Nick Clemens (kidclamp) 2022-03-31 13:18:18 UTC
Bug 26346 added an option for all staff to be able to manage contents of a public list, and a permission to allow staff to edit the configuration of public lists.

It would be nice to go more granular and add a permission that allow users with this permission to edit list contents, and a setting to follow this permission for a list
Comment 1 Katrin Fischer 2022-04-03 11:08:05 UTC
Hi Nick,

I have read it several times, but I am not sure I understand yet what the new permissions would look like. Maybe you could write them up?
Comment 2 Sally 2022-07-27 11:05:11 UTC
+1 

Really interested in this development.
Comment 3 Alex Buckley 2022-08-24 01:06:26 UTC
Created attachment 139696 [details] [review]
Bug 30418: Database changes

Sponsored-by: Catalyst IT, New Zealand
Comment 4 Alex Buckley 2022-08-24 01:06:47 UTC
Created attachment 139697 [details] [review]
Bug 30418: Updated schema file

Sponsored-by: Catalyst IT, New Zealand
Comment 5 Alex Buckley 2022-08-24 01:07:07 UTC
Created attachment 139698 [details] [review]
Bug 30418: Template and JavaScript changes

Sponsored-by: Catalyst IT, New Zealand
Comment 6 Alex Buckley 2022-08-24 01:07:54 UTC
Created attachment 139699 [details] [review]
Bug 30418: Add ability for permitted staff to edit list contents

Public lists with 'Allow changes to contents from' = 'Permitted staff only'
can have their contents managed by Koha patrons with either of the
permissions below:

- superlibrarian permission
- catalogue permission + 'edit_public_list_contents' sub-permission

Test plan:
1. Apply patches, update database, restart services
2. In the staff client go to: Lists > New List
3. Create a list, choose 'Allow changes to contents from' => 'Permitted
staff only'

4. Log into the OPAC as a patron with no permissions.
5. Confirm you CANNOT add a biblio to the list from the OPAC search result page and
OPAC biblio detail pages

6. Log into the OPAC as a patron with only the 'catalogue' permissions
enabled
7. Confirm you CANNOT add a biblio to the list from OPAC search result
or biblio detail pages

8. Log into the OPAC as a patron with the 'catalogue' and
'edit_public_list_contents' permissions enabled
9. Confirm you CAN add/remove biblios from the OPAC search result and
biblio detail pages

10. Log into the OPAC as a patron with superlibrarian permissions
11. Confirm you CAN add a biblio to the list from the OPAC search result
page and OPAC biblio detail pages

12. Log into the staff client as a patron with only the
'catalogue' permission and confirm you CANNOT add/remove records from the
list

13. Log into the staff client as a patron with the 'catalogue' and
'edit_public_list_contents' sub-permission (found under 'Lists' parent
permission)
14. Confirm you CAN add/remove records from the list

15. Login into thestaff client as a patron with 'superlibrarian'
permissions and confirm you CAN add/remove records from the list

Sponsored-by: Catalyst IT, New Zealand
Comment 7 Alex Buckley 2022-08-24 01:08:15 UTC
Created attachment 139700 [details] [review]
Bug 30418: Unit tests

Test plan:
1. Run unit tests
sudo koha-shell <instance>
prove t/db_dependent/Koha/Patron.t
prove t/db_dependent/Virtualshelves.t

Sponsored-by: Catalyst IT, New Zealand
Comment 8 Alex Buckley 2022-08-24 01:08:35 UTC
Created attachment 139701 [details] [review]
Bug 30418: Re-order options of who can edit list contents

The 'Allow changes to contents from' dropdown when creating/edit lists
should be most locked down to least locked down:

1. Nobody
2. Owner only
3. Permitted staff only
4. Staff only
5. Anyone seeing this list

Sponsored-by: Catalyst IT, New Zealand
Comment 9 Alex Buckley 2022-08-24 01:32:16 UTC
This is now ready to test. I have named the new 'Allow changes to contents from' dropdown option 'Permitted staff only'. I'm happy to change this naming to 'Staff with permissions' or other variations if you think it might clarify what it does.
Comment 10 Hammat wele 2022-11-18 14:52:11 UTC
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
error: Failed to merge in the changes.Patch failed at 0001 Bug 30418: Template and JavaScript changes
Comment 11 Alex Buckley 2023-02-07 22:03:57 UTC
Created attachment 146363 [details] [review]
Bug 30418: Database changes

Sponsored-by: Catalyst IT, New Zealand
Comment 12 Alex Buckley 2023-02-07 22:04:24 UTC
Created attachment 146364 [details] [review]
Bug 30418: Updated schema file

Sponsored-by: Catalyst IT, New Zealand
Comment 13 Alex Buckley 2023-02-07 22:04:45 UTC
Created attachment 146365 [details] [review]
Bug 30418: Template and JavaScript changes

Sponsored-by: Catalyst IT, New Zealand
Comment 14 Alex Buckley 2023-02-07 22:05:07 UTC
Created attachment 146366 [details] [review]
Bug 30418: Add ability for permitted staff to edit list contents

Public lists with 'Allow changes to contents from' = 'Permitted staff only'
can have their contents managed by Koha patrons with either of the
permissions below:

- superlibrarian permission
- catalogue permission + 'edit_public_list_contents' sub-permission

Test plan:
1. Apply patches, update database, restart services
2. In the staff client go to: Lists > New List
3. Create a list, choose 'Allow changes to contents from' => 'Permitted
staff only'

4. Log into the OPAC as a patron with no permissions.
5. Confirm you CANNOT add a biblio to the list from the OPAC search result page and
OPAC biblio detail pages

6. Log into the OPAC as a patron with only the 'catalogue' permissions
enabled
7. Confirm you CANNOT add a biblio to the list from OPAC search result
or biblio detail pages

8. Log into the OPAC as a patron with the 'catalogue' and
'edit_public_list_contents' permissions enabled
9. Confirm you CAN add/remove biblios from the OPAC search result and
biblio detail pages

10. Log into the OPAC as a patron with superlibrarian permissions
11. Confirm you CAN add a biblio to the list from the OPAC search result
page and OPAC biblio detail pages

12. Log into the staff client as a patron with only the
'catalogue' permission and confirm you CANNOT add/remove records from the
list

13. Log into the staff client as a patron with the 'catalogue' and
'edit_public_list_contents' sub-permission (found under 'Lists' parent
permission)
14. Confirm you CAN add/remove records from the list

15. Login into thestaff client as a patron with 'superlibrarian'
permissions and confirm you CAN add/remove records from the list

Sponsored-by: Catalyst IT, New Zealand
Comment 15 Alex Buckley 2023-02-07 22:05:23 UTC
Created attachment 146367 [details] [review]
Bug 30418: Unit tests

Test plan:
1. Run unit tests
sudo koha-shell <instance>
prove t/db_dependent/Koha/Patron.t
prove t/db_dependent/Virtualshelves.t

Sponsored-by: Catalyst IT, New Zealand
Comment 16 Alex Buckley 2023-02-07 22:05:44 UTC
Created attachment 146368 [details] [review]
Bug 30418: Re-order options of who can edit list contents

The 'Allow changes to contents from' dropdown when creating/edit lists
should be most locked down to least locked down:

1. Nobody
2. Owner only
3. Permitted staff only
4. Staff only
5. Anyone seeing this list

Sponsored-by: Catalyst IT, New Zealand
Comment 17 Alex Buckley 2023-02-07 22:06:07 UTC
Rebased against master. Ready for testing again
Comment 18 Lucas Gass (lukeg) 2023-02-08 00:22:51 UTC
Works as describe and tests pass
Comment 19 Lucas Gass (lukeg) 2023-02-08 00:24:07 UTC
Created attachment 146374 [details] [review]
Bug 30418: Database changes

Sponsored-by: Catalyst IT, New Zealand
Comment 20 Lucas Gass (lukeg) 2023-02-08 00:24:10 UTC
Created attachment 146375 [details] [review]
Bug 30418: Updated schema file

Sponsored-by: Catalyst IT, New Zealand
Comment 21 Lucas Gass (lukeg) 2023-02-08 00:24:12 UTC
Created attachment 146376 [details] [review]
Bug 30418: Template and JavaScript changes

Sponsored-by: Catalyst IT, New Zealand
Comment 22 Lucas Gass (lukeg) 2023-02-08 00:24:15 UTC
Created attachment 146377 [details] [review]
Bug 30418: Add ability for permitted staff to edit list contents

Public lists with 'Allow changes to contents from' = 'Permitted staff only'
can have their contents managed by Koha patrons with either of the
permissions below:

- superlibrarian permission
- catalogue permission + 'edit_public_list_contents' sub-permission

Test plan:
1. Apply patches, update database, restart services
2. In the staff client go to: Lists > New List
3. Create a list, choose 'Allow changes to contents from' => 'Permitted
staff only'

4. Log into the OPAC as a patron with no permissions.
5. Confirm you CANNOT add a biblio to the list from the OPAC search result page and
OPAC biblio detail pages

6. Log into the OPAC as a patron with only the 'catalogue' permissions
enabled
7. Confirm you CANNOT add a biblio to the list from OPAC search result
or biblio detail pages

8. Log into the OPAC as a patron with the 'catalogue' and
'edit_public_list_contents' permissions enabled
9. Confirm you CAN add/remove biblios from the OPAC search result and
biblio detail pages

10. Log into the OPAC as a patron with superlibrarian permissions
11. Confirm you CAN add a biblio to the list from the OPAC search result
page and OPAC biblio detail pages

12. Log into the staff client as a patron with only the
'catalogue' permission and confirm you CANNOT add/remove records from the
list

13. Log into the staff client as a patron with the 'catalogue' and
'edit_public_list_contents' sub-permission (found under 'Lists' parent
permission)
14. Confirm you CAN add/remove records from the list

15. Login into thestaff client as a patron with 'superlibrarian'
permissions and confirm you CAN add/remove records from the list

Sponsored-by: Catalyst IT, New Zealand
Comment 23 Lucas Gass (lukeg) 2023-02-08 00:24:18 UTC
Created attachment 146378 [details] [review]
Bug 30418: Unit tests

Test plan:
1. Run unit tests
sudo koha-shell <instance>
prove t/db_dependent/Koha/Patron.t
prove t/db_dependent/Virtualshelves.t

Sponsored-by: Catalyst IT, New Zealand
Comment 24 Lucas Gass (lukeg) 2023-02-08 00:24:21 UTC
Created attachment 146379 [details] [review]
Bug 30418: Re-order options of who can edit list contents

The 'Allow changes to contents from' dropdown when creating/edit lists
should be most locked down to least locked down:

1. Nobody
2. Owner only
3. Permitted staff only
4. Staff only
5. Anyone seeing this list

Sponsored-by: Catalyst IT, New Zealand
Comment 25 Alex Buckley 2023-02-14 04:25:55 UTC
Created attachment 146609 [details] [review]
Bug 30418: (follow-up) Fixes for QA test tools

Sponsored-by: Catalyst IT, New Zealand
Comment 26 Kyle M Hall (khall) 2023-03-24 10:52:42 UTC
Created attachment 148645 [details] [review]
Bug 30418: Database changes

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 27 Kyle M Hall (khall) 2023-03-24 10:52:50 UTC
Created attachment 148646 [details] [review]
Bug 30418: Updated schema file

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 28 Kyle M Hall (khall) 2023-03-24 10:52:52 UTC
Created attachment 148647 [details] [review]
Bug 30418: Template and JavaScript changes

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 29 Kyle M Hall (khall) 2023-03-24 10:52:54 UTC
Created attachment 148648 [details] [review]
Bug 30418: Add ability for permitted staff to edit list contents

Public lists with 'Allow changes to contents from' = 'Permitted staff only'
can have their contents managed by Koha patrons with either of the
permissions below:

- superlibrarian permission
- catalogue permission + 'edit_public_list_contents' sub-permission

Test plan:
1. Apply patches, update database, restart services
2. In the staff client go to: Lists > New List
3. Create a list, choose 'Allow changes to contents from' => 'Permitted
staff only'

4. Log into the OPAC as a patron with no permissions.
5. Confirm you CANNOT add a biblio to the list from the OPAC search result page and
OPAC biblio detail pages

6. Log into the OPAC as a patron with only the 'catalogue' permissions
enabled
7. Confirm you CANNOT add a biblio to the list from OPAC search result
or biblio detail pages

8. Log into the OPAC as a patron with the 'catalogue' and
'edit_public_list_contents' permissions enabled
9. Confirm you CAN add/remove biblios from the OPAC search result and
biblio detail pages

10. Log into the OPAC as a patron with superlibrarian permissions
11. Confirm you CAN add a biblio to the list from the OPAC search result
page and OPAC biblio detail pages

12. Log into the staff client as a patron with only the
'catalogue' permission and confirm you CANNOT add/remove records from the
list

13. Log into the staff client as a patron with the 'catalogue' and
'edit_public_list_contents' sub-permission (found under 'Lists' parent
permission)
14. Confirm you CAN add/remove records from the list

15. Login into thestaff client as a patron with 'superlibrarian'
permissions and confirm you CAN add/remove records from the list

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 30 Kyle M Hall (khall) 2023-03-24 10:52:57 UTC
Created attachment 148649 [details] [review]
Bug 30418: Unit tests

Test plan:
1. Run unit tests
sudo koha-shell <instance>
prove t/db_dependent/Koha/Patron.t
prove t/db_dependent/Virtualshelves.t

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 31 Kyle M Hall (khall) 2023-03-24 10:52:59 UTC
Created attachment 148650 [details] [review]
Bug 30418: Re-order options of who can edit list contents

The 'Allow changes to contents from' dropdown when creating/edit lists
should be most locked down to least locked down:

1. Nobody
2. Owner only
3. Permitted staff only
4. Staff only
5. Anyone seeing this list

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 32 Kyle M Hall (khall) 2023-03-24 10:53:01 UTC
Created attachment 148651 [details] [review]
Bug 30418: (follow-up) Fixes for QA test tools

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 33 Kyle M Hall (khall) 2023-03-24 10:53:04 UTC
Created attachment 148652 [details] [review]
Bug 30418: (QA follow-up): Fix unit test count

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 34 Tomás Cohen Arazi (tcohen) 2023-05-15 21:16:57 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 35 Jonathan Druart 2023-05-16 07:55:52 UTC
Created attachment 151249 [details] [review]
Bug 30418: Fix t/Koha/Auth/Permissions.t

koha_1       |     #   Failed test 'Expected permissions generated for superlibrarian'
koha_1       |     #   at t/Koha/Auth/Permissions.t line 283.
koha_1       |     #     Structures begin differing at:
koha_1       |     #          $got->{CAN_user_lists_edit_public_list_contents} = '1'
koha_1       |     #     $expected->{CAN_user_lists_edit_public_list_contents} = Does not exist
koha_1       |     # Looks like you failed 1 test of 1.
koha_1       |
koha_1       | #   Failed test 'superlibrarian tests'
koha_1       | #   at t/Koha/Auth/Permissions.t line 284.
koha_1       | # Looks like you failed 1 test of 3.
koha_1       | [23:34:42] t/Koha/Auth/Permissions.t
Comment 36 Jonathan Druart 2023-05-16 09:28:06 UTC
(In reply to Jonathan Druart from comment #35)
> Created attachment 151249 [details] [review] [review]
> Bug 30418: Fix t/Koha/Auth/Permissions.t
> 
> koha_1       |     #   Failed test 'Expected permissions generated for
> superlibrarian'
> koha_1       |     #   at t/Koha/Auth/Permissions.t line 283.
> koha_1       |     #     Structures begin differing at:
> koha_1       |     #         
> $got->{CAN_user_lists_edit_public_list_contents} = '1'
> koha_1       |     #    
> $expected->{CAN_user_lists_edit_public_list_contents} = Does not exist
> koha_1       |     # Looks like you failed 1 test of 1.
> koha_1       |
> koha_1       | #   Failed test 'superlibrarian tests'
> koha_1       | #   at t/Koha/Auth/Permissions.t line 284.
> koha_1       | # Looks like you failed 1 test of 3.
> koha_1       | [23:34:42] t/Koha/Auth/Permissions.t

Pushed to master.
Comment 37 Marcel de Rooy 2023-05-17 12:04:40 UTC
Hmm We have problems with permissions now. Could this one be the cause?
Comment 38 Marcel de Rooy 2023-05-17 12:24:03 UTC
(In reply to Marcel de Rooy from comment #37)
> Hmm We have problems with permissions now. Could this one be the cause?

Still looking btw
Comment 39 Alex Buckley 2023-05-18 02:22:15 UTC
Hi Marcel, 

According to comment #36 this enhancement (bug 30418) was pushed to master around 2023-05-16 09:28:06 UTC, however, the list permission problems in bug 33722 were reported earlier at 2023-05-11 23:16:42 UTC 

Also, noting that if you checkout 2928c1cf634c97041ea3b1268dcc27a550feb2ca 'Bug 32775: (QA follow-up) remove useless empty line' (the commit in log before bug 30418 was pushed) the problem reported in bug 33722 can be replicated then. 

Alex
Comment 40 Marcel de Rooy 2023-05-18 08:39:54 UTC
(In reply to Alex Buckley from comment #39)
> Hi Marcel, 
> 
> According to comment #36 this enhancement (bug 30418) was pushed to master
> around 2023-05-16 09:28:06 UTC, however, the list permission problems in bug
> 33722 were reported earlier at 2023-05-11 23:16:42 UTC 
> 
> Also, noting that if you checkout 2928c1cf634c97041ea3b1268dcc27a550feb2ca
> 'Bug 32775: (QA follow-up) remove useless empty line' (the commit in log
> before bug 30418 was pushed) the problem reported in bug 33722 can be
> replicated then. 
> 
> Alex

Might be false alarm indeed. Sorry for the confusion.
Comment 41 Alex Buckley 2023-05-18 21:50:40 UTC
(In reply to Marcel de Rooy from comment #40)
> (In reply to Alex Buckley from comment #39)
> > Hi Marcel, 
> > 
> > According to comment #36 this enhancement (bug 30418) was pushed to master
> > around 2023-05-16 09:28:06 UTC, however, the list permission problems in bug
> > 33722 were reported earlier at 2023-05-11 23:16:42 UTC 
> > 
> > Also, noting that if you checkout 2928c1cf634c97041ea3b1268dcc27a550feb2ca
> > 'Bug 32775: (QA follow-up) remove useless empty line' (the commit in log
> > before bug 30418 was pushed) the problem reported in bug 33722 can be
> > replicated then. 
> > 
> > Alex
> 
> Might be false alarm indeed. Sorry for the confusion.

No worries, thanks Marcel
Comment 42 Matt Blenkinsop 2023-06-02 16:14:15 UTC
Enhancement - not backporting to 22.11.x