Bugzilla – Attachment 172370 Details for
Bug 36372
Allow privileged users to set the 'record source' on cataloguing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36372: provide an interface to set the source of a record from the staff interface
Bug-36372-provide-an-interface-to-set-the-source-o.patch (text/plain), 9.96 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-10-03 19:13:49 UTC
(
hide
)
Description:
Bug 36372: provide an interface to set the source of a record from the staff interface
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-10-03 19:13:49 UTC
Size:
9.96 KB
patch
obsolete
>From 5bcf79cfe7fbcdb9aea19b18a6527d8e1b1c9b09 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Wed, 1 May 2024 23:33:47 +0200 >Subject: [PATCH] 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> >--- > cataloguing/record_source.pl | 68 +++++++++++++++++++ > .../prog/en/includes/cat-toolbar.inc | 8 ++- > .../en/modules/cataloguing/record_source.tt | 65 ++++++++++++++++++ > .../integration/Catalogue/Detail_spec.ts | 6 +- > 4 files changed, 143 insertions(+), 4 deletions(-) > create mode 100755 cataloguing/record_source.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/record_source.tt > >diff --git a/cataloguing/record_source.pl b/cataloguing/record_source.pl >new file mode 100755 >index 00000000000..d9fbd87242c >--- /dev/null >+++ b/cataloguing/record_source.pl >@@ -0,0 +1,68 @@ >+#!/usr/bin/perl >+ >+# Copyright 2000-2002 Katipo Communications >+# Copyright 2004-2010 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI; >+use C4::Output qw( output_html_with_http_headers ); >+use C4::Auth qw( get_template_and_user haspermission ); >+use C4::Biblio qw( ModBiblio ); >+use C4::Context; >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::Biblios; >+use Koha::RecordSources; >+use Koha::SearchEngine; >+use Koha::SearchEngine::Indexer; >+use URI::Escape qw( uri_escape_utf8 ); >+ >+# ======================== >+# MAIN >+#========================= >+my $input = CGI->new; >+my $biblionumber = $input->param('biblionumber'); >+my $record_source_id = $input->param('record_source_id') // ''; >+my $save = $input->param('save') // ''; >+my $biblio = Koha::Biblios->find($biblionumber); >+ >+if ($save) { >+ $biblio->metadata->set( { record_source_id => $record_source_id } )->store; >+ my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >+ $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); >+ print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber"); >+} >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "cataloguing/record_source.tt", >+ query => $input, >+ type => "intranet", >+ flagsrequired => { editcatalogue => 'set_record_sources' }, >+ } >+); >+ >+my $record_sources = Koha::RecordSources->search(); >+ >+$template->param( >+ biblio => $biblio, >+ record_sources => $record_sources, >+ current_source => { record_source_id => $biblio->metadata->record_source_id }, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >index 4b99bbea279..6bd62709f79 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -35,7 +35,7 @@ > </div> > [% END %] > >-[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] >+[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_editcatalogue_set_record_sources ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] > <div class="btn-group"> > <button class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</button> > <ul class="dropdown-menu"> >@@ -47,6 +47,12 @@ > [% END %] > [% END %] > >+ [% IF CAN_user_editcatalogue_set_record_sources %] >+ <li><a id="setrecordsource" href="/cgi-bin/koha/cataloguing/record_source.pl?biblionumber=[% biblionumber | html %]">Set record source</a></li> >+ [% ELSE %] >+ <li class="disabled"><a id="setrecordsource" href="#">Set record source</a></li> >+ [% END %] >+ > [% IF CAN_user_tools_records_batchmod %] > <li> > <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/record_source.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/record_source.tt >new file mode 100644 >index 00000000000..c6651624f6a >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/record_source.tt >@@ -0,0 +1,65 @@ >+[% USE raw %] >+[% PROCESS 'i18n.inc' %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>[% FILTER collapse %] >+ [% t("Set record sources for") | html %] [% INCLUDE 'biblio-title-head.inc' %] › >+ [% t("Cataloging") | html %] › >+ [% t("Koha") | html %] >+[% END %]</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="catalog_set_record_source" class="catalog"> >+[% WRAPPER 'header.inc' %] >+ [% INCLUDE 'cat-search.inc' %] >+[% END %] >+ >+[% WRAPPER 'sub-header.inc' %] >+ [% WRAPPER breadcrumbs %] >+ [% WRAPPER breadcrumb_item %] >+ <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> >+ [% END %] >+ [% WRAPPER breadcrumb_item %] >+ [% INCLUDE 'biblio-title.inc' link = 1 %] >+ [% END %] >+ [% WRAPPER breadcrumb_item bc_active= 1 %] >+ <span>Set record's source</span> >+ [% END %] >+ [% END #/ WRAPPER breadcrumbs %] >+[% END #/ WRAPPER sub-header.inc %] >+ >+[% SWITCH Koha.Preference('IntranetBiblioDefaultView') %] >+[% CASE 'marc' %] [% action_link = "/cgi-bin/koha/catalogue/MARCdetail.pl" %] >+[% CASE 'labeled_marc' %] [% action_link = "/cgi-bin/koha/catalogue/labeledMARCdetail.pl" %] >+[% CASE 'isbd' %] [% action_link = "/cgi-bin/koha/catalogue/ISBDdetail.pl" %] >+[% CASE %] [% action_link = "/cgi-bin/koha/catalogue/detail.pl" %] >+[% END %] >+[% action_link = action_link _ '?biblionumber=' _ biblio.biblionumber %] >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"> >+ [% INCLUDE 'messages.inc' %] >+ >+ <h1>Set the record source [% IF ( biblio.title ) %] for [% INCLUDE 'biblio-title.inc' %][% END %]</h1> >+ >+ <form method="get" action="/cgi-bin/koha/cataloguing/record_source.pl"> >+ <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html_entity %]" /> >+ <select id="record_source_id" name="record_source_id"> >+ <option value=''>No specified source</option> >+ [% FOREACH source IN record_sources %] >+ [% IF ( source.record_source_id == current_source.record_source_id ) %] >+ <option value="[% source.record_source_id | html_entity %]" selected="selected">[% source.name | html_entity %]</option> >+ [% ELSE %] >+ <option value="[% source.record_source_id | html_entity %]">[% source.name | html_entity %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <div class="btn-group"> >+ <input type="submit" name="save" class="btn btn-primary" value="Set record source" /> >+ <a class="btn btn-secondary" href="/cgi-bin/koha/admin/record_sources">Configure record sources</a> >+ </div> >+ </form> >+ </div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/t/cypress/integration/Catalogue/Detail_spec.ts b/t/cypress/integration/Catalogue/Detail_spec.ts >index 8175a4b3d60..b3cd2b90177 100644 >--- a/t/cypress/integration/Catalogue/Detail_spec.ts >+++ b/t/cypress/integration/Catalogue/Detail_spec.ts >@@ -17,9 +17,9 @@ describe("Set record_source button is present", () => { > cy.get("select").select("No specified source"); > cy.get("input[type=submit]").click(); > >- cy.intercept("GET", '/api/v1/record_sources*').as('listSources') >+ cy.intercept("GET", "/api/v1/record_sources*").as("listSources"); > cy.visit("/cgi-bin/koha/admin/record_sources"); >- cy.wait('@listSources') >+ cy.wait("@listSources"); > cy.get("tr:last-child a.delete").click(); > cy.contains("Poop"); > cy.get("button.approve").click(); >@@ -34,4 +34,4 @@ describe("Set record_source button is present", () => { > cy.visit("/cgi-bin/koha/catalogue/detail.pl?biblionumber=51"); > cy.get("#catalogue_detail_record_source").contains("Poop"); > }); >-}); >\ No newline at end of file >+}); >-- >2.46.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36372
:
166161
|
168054
|
168195
|
168338
|
168339
|
168340
|
168430
|
168510
|
168511
|
168512
|
168897
|
168898
|
168899
|
168900
|
168902
|
169268
|
169269
|
169270
|
169271
|
169542
|
169831
|
172369
|
172370
|
172371
|
176743
|
176744
|
177467
|
177468