Bug 36372 - Allow privileged users to set the 'record source' on cataloguing
Summary: Allow privileged users to set the 'record source' on cataloguing
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Arthur Suzuki
QA Contact: Tomás Cohen Arazi (tcohen)
URL:
Keywords:
Depends on: 37419 31791
Blocks: 36884
  Show dependency treegraph
 
Reported: 2024-03-20 14:29 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2024-10-07 14:56 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 36372: provide an interface to set the source of a record from the staff interface (6.24 KB, patch)
2024-05-04 01:34 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372 : trigger a record indexing when the record source is set (1.31 KB, patch)
2024-06-25 11:45 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372 : Cypress tests (2.17 KB, patch)
2024-06-27 11:47 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: provide an interface to set the source of a record from the staff interface (6.95 KB, patch)
2024-07-02 09:43 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: trigger a record indexing when the record source is set (1.53 KB, patch)
2024-07-02 09:43 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: Cypress tests (2.17 KB, patch)
2024-07-02 09:43 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: provide an interface to set the source of a record from the staff interface (6.93 KB, patch)
2024-07-03 09:43 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: Cypress tests (2.22 KB, patch)
2024-07-04 19:48 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: provide an interface to set the source of a record from the staff interface (6.98 KB, patch)
2024-07-04 19:48 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: trigger a record indexing when the record source is set (1.58 KB, patch)
2024-07-04 19:48 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: Cypress tests (2.17 KB, patch)
2024-07-12 12:18 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: provide an interface to set the source of a record from the staff interface (8.27 KB, patch)
2024-07-12 12:18 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: trigger a record indexing when the record source is set (1.53 KB, patch)
2024-07-12 12:18 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: (QA follow-up) perltidy cataloguing/record_source.pl, fix permissions issues, add html filters to new template# (5.82 KB, patch)
2024-07-12 12:18 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: (QA follow-up) perltidy cataloguing/record_source.pl, fix permissions issues, add html filters to new template# (5.86 KB, patch)
2024-07-12 13:01 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: Cypress tests (2.22 KB, patch)
2024-07-22 09:57 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: provide an interface to set the source of a record from the staff interface (8.32 KB, patch)
2024-07-22 09:57 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: trigger a record indexing when the record source is set (1.58 KB, patch)
2024-07-22 09:57 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: (QA follow-up) perltidy cataloguing/record_source.pl, fix permissions issues, add html filters to new template# (5.91 KB, patch)
2024-07-22 09:57 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: (QA followup) pass current record-source to template while editing (1.36 KB, patch)
2024-07-25 07:39 UTC, Arthur Suzuki
Details | Diff | Splinter Review
Bug 36372: (QA followup) pass current record-source to template while editing (1.41 KB, patch)
2024-07-29 12:32 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36372: Cypress tests (2.22 KB, patch)
2024-10-03 19:13 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 36372: provide an interface to set the source of a record from the staff interface (9.96 KB, patch)
2024-10-03 19:13 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 36372: Fix style issues in dropdown (1.52 KB, patch)
2024-10-03 19:13 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2024-03-20 14:29:17 UTC
This would be handy, as right now it can only be set through an API request.
Comment 1 Arthur Suzuki 2024-04-22 22:03:42 UTC
+1 that would be handy!
Also, tomas forgot to mention, the api may set the record source upon creation of a record (which is great) but there is no way to change it (even with the api) once it's created.
Then the only way to change it is through a direct access to the database.
In some use-cases it may be needed that a librarian "unlock" a record to let a fellow edit the record.
Comment 2 Arthur Suzuki 2024-05-04 01:34:48 UTC
Created attachment 166161 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface
Comment 3 Fridolin Somers 2024-05-24 08:03:25 UTC
Isn't it a done by Bug 35919 ?
Comment 4 Arthur Suzuki 2024-06-24 14:01:50 UTC
(In reply to Fridolin Somers from comment #3)
> Isn't it a done by Bug 35919 ?

it is not, Bug 35919 provides all the logic but no interface. Which this bug does (based on the logic provided by bug 35919).
Comment 5 Arthur Suzuki 2024-06-25 11:45:01 UTC
Created attachment 168054 [details] [review]
Bug 36372 : trigger a record indexing when the record source is set
Comment 6 Arthur Suzuki 2024-06-27 11:47:00 UTC
Created attachment 168195 [details] [review]
Bug 36372 : Cypress tests
Comment 7 Arthur Suzuki 2024-07-02 09:43:37 UTC
Created attachment 168338 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface

Test plan :
- apply Cypress patch
- running cypress patch in ktd will fail
- apply both code patches, cypress tests will pass
- open any record in the staff interface
- with superlibrarian user, click on the "Edit" button group.
- you should be able to click on the "Set record source" below the "Edit record button".
- you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources.
- change a users permissions to have cataloguing permissions but without the "set_record_source" permissions.
- login as this forementionned user and go to any record view.
- the "Set record source" button should now be greyed out and not possible to click.#
Comment 8 Arthur Suzuki 2024-07-02 09:43:40 UTC
Created attachment 168339 [details] [review]
Bug 36372: trigger a record indexing when the record source is set
Comment 9 Arthur Suzuki 2024-07-02 09:43:43 UTC
Created attachment 168340 [details] [review]
Bug 36372: Cypress tests
Comment 10 Arthur Suzuki 2024-07-03 09:43:43 UTC
Created attachment 168430 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface

Test plan :
- apply Cypress patch
- running cypress patch in ktd will fail
- apply both code patches, cypress tests will pass
- open any record in the staff interface
- with superlibrarian user, click on the "Edit" button group.
- you should be able to click on the "Set record source" below the "Edit record button".
- you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources.
- change a users permissions to have cataloguing permissions but without the "set_record_source" permissions.
- login as this forementionned user and go to any record view.
- the "Set record source" button should now be greyed out and not possible to click.#
Comment 11 Janusz Kaczmarek 2024-07-04 19:48:34 UTC
Created attachment 168510 [details] [review]
Bug 36372: Cypress tests

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 12 Janusz Kaczmarek 2024-07-04 19:48:37 UTC
Created attachment 168511 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface

Test plan :
- apply Cypress patch
- running cypress patch in ktd will fail
- apply both code patches, cypress tests will pass
- open any record in the staff interface
- with superlibrarian user, click on the "Edit" button group.
- you should be able to click on the "Set record source" below the "Edit record button".
- you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources.
- change a users permissions to have cataloguing permissions but without the "set_record_source" permissions.
- login as this forementionned user and go to any record view.
- the "Set record source" button should now be greyed out and not possible to click.#

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 13 Janusz Kaczmarek 2024-07-04 19:48:39 UTC
Created attachment 168512 [details] [review]
Bug 36372: trigger a record indexing when the record source is set

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 14 Janusz Kaczmarek 2024-07-04 19:53:12 UTC
Post test remarks:

0) Works as declared.

1) To make cypress test happy for the second run, I had to manually delete Poop source created in  the first run.

2) It was necessary to apply interactively "trigger a record indexing when the record source is set" only after "provide an interface to set the source of a record from the staff interface" was already applied.  Otherwise an error results.

3) QA scripts unhappy.
Comment 15 Arthur Suzuki 2024-07-12 12:18:39 UTC
Created attachment 168897 [details] [review]
Bug 36372: Cypress tests
Comment 16 Arthur Suzuki 2024-07-12 12:18:51 UTC
Created attachment 168898 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface

Test plan :
- apply Cypress patch
- running cypress patch in ktd will fail
- apply both code patches, cypress tests will pass
- open any record in the staff interface
- with superlibrarian user, click on the "Edit" button group.
- you should be able to click on the "Set record source" below the "Edit record button".
- you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources.
- change a users permissions to have cataloguing permissions but without the "set_record_source" permissions.
- login as this forementionned user and go to any record view.
- the "Set record source" button should now be greyed out and not possible to click.#
Comment 17 Arthur Suzuki 2024-07-12 12:18:55 UTC
Created attachment 168899 [details] [review]
Bug 36372: trigger a record indexing when the record source is set
Comment 18 Arthur Suzuki 2024-07-12 12:18:58 UTC
Created attachment 168900 [details] [review]
Bug 36372: (QA follow-up) perltidy cataloguing/record_source.pl, fix permissions issues, add html filters to new template#
Comment 19 Arthur Suzuki 2024-07-12 12:22:37 UTC
Hi,
I have re-uploaded the patch in the correct order + made a followup patch to fix the issues from the qa scripts.
Can anyone make signoff again?
Comment 20 Arthur Suzuki 2024-07-12 13:01:30 UTC
Created attachment 168902 [details] [review]
Bug 36372: (QA follow-up) perltidy cataloguing/record_source.pl, fix permissions issues, add html filters to new template#
Comment 21 Janusz Kaczmarek 2024-07-12 13:07:26 UTC
Arthur,

it does not work for me.  After clicking the button "Set record source" from /cgi-bin/koha/cataloguing/record_source.pl?biblionumber=111, I'm getting:

/cgi-bin/koha/cataloguing/record_source.pl?biblionumber=&record_source_id=4&save=Set+record+source

Note, without biblionumber.

And in record_source.pl you are not checking if the $biblionumber is present and correct nor if Koha::Biblios->find gave you a valid object.  As a result my ktd exploded with:

Can't call method "metadata" on an undefined value at /kohadevbox/koha/cataloguing/record_source.pl line 45
Comment 22 Janusz Kaczmarek 2024-07-12 13:24:31 UTC
After the recent correction of 2024-07-12 13:01 UTC it seems to work.  

But there is a serious issue with deleting the record source--when you delete a record source already used in some records, it seem delete also biblio_metadata rows linked with that biblio_metadata.record_source_id.  The biblio and biblioitems rows remain, but biblio_metadata is gone. 

Could you confirm it please?  Is it universal problem or is it connected only with some local circumstances?
Comment 23 Janusz Kaczmarek 2024-07-22 09:57:48 UTC
Created attachment 169268 [details] [review]
Bug 36372: Cypress tests

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 24 Janusz Kaczmarek 2024-07-22 09:57:51 UTC
Created attachment 169269 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface

Test plan :
- apply Cypress patch
- running cypress patch in ktd will fail
- apply both code patches, cypress tests will pass
- open any record in the staff interface
- with superlibrarian user, click on the "Edit" button group.
- you should be able to click on the "Set record source" below the "Edit record button".
- you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources.
- change a users permissions to have cataloguing permissions but without the "set_record_source" permissions.
- login as this forementionned user and go to any record view.
- the "Set record source" button should now be greyed out and not possible to click.#

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 25 Janusz Kaczmarek 2024-07-22 09:57:54 UTC
Created attachment 169270 [details] [review]
Bug 36372: trigger a record indexing when the record source is set

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 26 Janusz Kaczmarek 2024-07-22 09:57:57 UTC
Created attachment 169271 [details] [review]
Bug 36372: (QA follow-up) perltidy cataloguing/record_source.pl, fix permissions issues, add html filters to new template#

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 27 Janusz Kaczmarek 2024-07-22 09:59:34 UTC
Signed-off, but still some issues with tidiness:

 WARN   cataloguing/record_source.pl
   WARN   tidiness
                The file is less tidy than before (bad/messy lines before: 0, now: 2)
Comment 28 Janusz Kaczmarek 2024-07-23 13:12:18 UTC
Arthur, just another remark.  It seems that the template cataloguing/record_source.tt was prepared to display the current record source if already set.  But it is not shown because the current record source (current_source.record_source_id) is not passed in the template call.

The following change would be a possible fix:

diff --git a/cataloguing/record_source.pl b/cataloguing/record_source.pl
index 1005e1aa1f..61579ef5d6 100755
--- a/cataloguing/record_source.pl
+++ b/cataloguing/record_source.pl
@@ -62,6 +62,7 @@ my $record_sources = Koha::RecordSources->search();
 $template->param(
     biblio   => $biblio,
     record_sources => $record_sources,
+    current_source => { record_source_id => $biblio->metadata->record_source_id },
 );
Comment 29 Arthur Suzuki 2024-07-25 07:39:56 UTC
Created attachment 169542 [details] [review]
Bug 36372: (QA followup) pass current record-source to template while editing
Comment 30 Janusz Kaczmarek 2024-07-29 12:32:12 UTC
Created attachment 169831 [details] [review]
Bug 36372: (QA followup) pass current record-source to template while editing

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 31 Tomás Cohen Arazi (tcohen) 2024-10-03 19:13:46 UTC
Created attachment 172369 [details] [review]
Bug 36372: Cypress tests

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 32 Tomás Cohen Arazi (tcohen) 2024-10-03 19:13:49 UTC
Created attachment 172370 [details] [review]
Bug 36372: provide an interface to set the source of a record from the staff interface

Test plan :
- apply Cypress patch
- running cypress patch in ktd will fail
- apply both code patches, cypress tests will pass
- open any record in the staff interface
- with superlibrarian user, click on the "Edit" button group.
- you should be able to click on the "Set record source" below the "Edit record button".
- you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources.
- change a users permissions to have cataloguing permissions but without the "set_record_source" permissions.
- login as this forementionned user and go to any record view.
- the "Set record source" button should now be greyed out and not possible to click.#

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 33 Tomás Cohen Arazi (tcohen) 2024-10-03 19:13:52 UTC
Created attachment 172371 [details] [review]
Bug 36372: Fix style issues in dropdown

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 34 Tomás Cohen Arazi (tcohen) 2024-10-03 19:17:51 UTC
A few remarks:

* I don't think we should introduce a new set of .pl+.tt this should be handled in a simple modal.
* The new page style is weird. Maybe a side-effect of the move to Bootstrap 5, cannot tell.
* The form for setting the record source is sending a GET (should be post)
* The form for setting the record source is not passing a CSRF token

It otherwise works as expected. My follow-up just makes it look the same as the rest of the dropdown (again, bootstrap 5 change side-effect).