Bugzilla – Attachment 175802 Details for
Bug 35380
PUT /biblios/:biblio_id doesn't respect overlay rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35380: Make record sources available in overlay rules
Bug-35380-Make-record-sources-available-in-overlay.patch (text/plain), 8.01 KB, created by
Jan Kissig
on 2024-12-19 19:10:47 UTC
(
hide
)
Description:
Bug 35380: Make record sources available in overlay rules
Filename:
MIME Type:
Creator:
Jan Kissig
Created:
2024-12-19 19:10:47 UTC
Size:
8.01 KB
patch
obsolete
>From 4f5701c67fda2e77e067bfa7a0ae830d344b1eba Mon Sep 17 00:00:00 2001 >From: Jan Kissig <bibliothek@th-wildau.de> >Date: Thu, 19 Dec 2024 11:13:00 +0000 >Subject: [PATCH] Bug 35380: Make record sources available in overlay rules > >This patch enhances the filters in record overlay rules when using the "Source" module. The available filter values are now system defined in Administration -> Record sources and can be extended by own record souces. The former hard coded values (f.e. batchmod, intranet) are added to the database and cannot be deleted. >--- > Koha/REST/V1/RecordSources.pm | 38 +++++++++++++++++++ > Koha/RecordSource.pm | 11 ++++++ > admin/marc-overlay-rules.pl | 5 +++ > api/v1/swagger/definitions/record_source.yaml | 1 - > api/v1/swagger/paths/record_sources.yaml | 15 ++++++++ > .../en/modules/admin/marc-overlay-rules.tt | 17 ++++++--- > 6 files changed, 80 insertions(+), 7 deletions(-) > >diff --git a/Koha/REST/V1/RecordSources.pm b/Koha/REST/V1/RecordSources.pm >index d51eaeacda..ea852aa868 100644 >--- a/Koha/REST/V1/RecordSources.pm >+++ b/Koha/REST/V1/RecordSources.pm >@@ -81,6 +81,17 @@ sub add { > openapi => $c->objects->to_api($source) > ); > } catch { >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { >+ return $c->render( >+ status => 409, >+ openapi => { error => 'Duplicate name.' } >+ ); >+ } elsif ( blessed $_ and $_->isa('Koha::Exceptions::BadParameter') ) { >+ return $c->render( >+ status => 409, >+ openapi => { error => 'Name not allowed.' } >+ ); >+ } > $c->unhandled_exception($_); > }; > } >@@ -97,11 +108,29 @@ sub update { > return $c->render_resource_not_found("Record source") > unless $source; > >+ if ( $source->is_system ) { >+ return $c->render( >+ status => 409, >+ openapi => { error => 'Cannot edit system defined value.' } >+ ); >+ } >+ > return try { > $source->set_from_api( $c->req->json )->store; > $source->discard_changes; > return $c->render( status => 200, openapi => $c->objects->to_api($source) ); > } catch { >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { >+ return $c->render( >+ status => 409, >+ openapi => { error => 'Duplicate name.' } >+ ); >+ } elsif ( blessed $_ and $_->isa('Koha::Exceptions::BadParameter') ) { >+ return $c->render( >+ status => 409, >+ openapi => { error => 'Name not allowed.' } >+ ); >+ } > $c->unhandled_exception($_); > }; > } >@@ -131,6 +160,15 @@ sub delete { > } > ); > } >+ elsif ( blessed $_ and $_->isa('Koha::Exceptions::CannotDeleteDefault') ) { >+ return $c->render( >+ status => 409, >+ openapi => { >+ error => 'Cannot delete system defined record source', >+ error_code => 'cannot_delete_is_system', >+ } >+ ); >+ } > $c->unhandled_exception($_); > }; > } >diff --git a/Koha/RecordSource.pm b/Koha/RecordSource.pm >index d92401f0dd..97391cb2c6 100644 >--- a/Koha/RecordSource.pm >+++ b/Koha/RecordSource.pm >@@ -46,6 +46,17 @@ sub usage_count { > return $self->_result->biblio_metadatas->count(); > } > >+=head3 store >+ >+=cut >+ >+sub store { >+ my ($self) = @_; >+ Koha::Exceptions::BadParameter->throw( '* not allowed' ) if $self->name eq '*'; >+ >+ return $self->SUPER::store; >+} >+ > =head3 delete > > Overridden delete method to prevent system default deletions >diff --git a/admin/marc-overlay-rules.pl b/admin/marc-overlay-rules.pl >index fc4c849e95..1150798de0 100755 >--- a/admin/marc-overlay-rules.pl >+++ b/admin/marc-overlay-rules.pl >@@ -26,6 +26,7 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::ImportBatch; > use Koha::MarcOverlayRules; > use Koha::Patron::Categories; >+use Koha::RecordSources; > > my $input = CGI->new; > my $op = $input->param('op') || ''; >@@ -124,9 +125,13 @@ elsif ($op eq 'cud-edit' || $op eq 'cud-add') { > my $categories = Koha::Patron::Categories->search_with_library_limits( {}, > { order_by => ['description'], columns => [ 'categorycode', 'description' ] } )->unblessed; > >+my @record_sources = >+ map { $_->{name} } @{ Koha::RecordSources->search->unblessed }; >+ > $template->param( > rules => $rules, > categories => $categories, >+ record_sources => \@record_sources, > messages => $errors > ); > >diff --git a/api/v1/swagger/definitions/record_source.yaml b/api/v1/swagger/definitions/record_source.yaml >index 6c1ff382eb..de52257e9b 100644 >--- a/api/v1/swagger/definitions/record_source.yaml >+++ b/api/v1/swagger/definitions/record_source.yaml >@@ -17,7 +17,6 @@ properties: > is_system: > description: Is this record source system or not > type: boolean >- readOnly: true > additionalProperties: false > required: > - name >diff --git a/api/v1/swagger/paths/record_sources.yaml b/api/v1/swagger/paths/record_sources.yaml >index 732368e2ae..dc197ac9f3 100644 >--- a/api/v1/swagger/paths/record_sources.yaml >+++ b/api/v1/swagger/paths/record_sources.yaml >@@ -97,6 +97,13 @@ > description: Not allowed > schema: > $ref: "../swagger.yaml#/definitions/error" >+ "409": >+ description: | >+ Conflict creating the resource. Possible `error_code` attribute values: >+ >+ * `duplicate` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" > "500": > description: | > Internal server error. Possible `error_code` attribute values: >@@ -198,6 +205,13 @@ > description: Not found > schema: > $ref: "../swagger.yaml#/definitions/error" >+ "409": >+ description: | >+ Conflict creating the resource. Possible `error_code` attribute values: >+ >+ * `duplicate` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" > "500": > description: | > Internal server error. Possible `error_code` attribute values: >@@ -248,6 +262,7 @@ > Conflict in deleting resource. Possible `error_code` attribute values: > > * `cannot_delete_used`: record source linked to a record cannot be deleted. >+ * `cannot_delete_is_system`: record source is system defined and cannot be deleted. > schema: > $ref: "../swagger.yaml#/definitions/error" > "500": >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt >index 437501950d..1a2efc7b1f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt >@@ -474,12 +474,17 @@ > var module_filter_options = { > source: { > '*': '*', >- batchmod: _("Batch record modification"), >- intranet: _("Staff interface MARC editor"), >- batchimport: _("Staged MARC import"), >- z3950: _("Z39.50"), >- bulkmarcimport: _("bulkmarcimport.pl"), >- import_lexile: _("import_lexile.pl") >+ [% FOREACH record_source IN record_sources %] >+ [% SWITCH record_source %] >+ [% CASE 'batchmod' %]'[% record_source %]': _("Batch record modification"), >+ [% CASE 'intranet' %]'[% record_source %]':_("Staff interface MARC editor"), >+ [% CASE 'batchimport' %]'[% record_source %]': _("Staged MARC import"), >+ [% CASE 'z3950' %]'[% record_source %]': _("Z39.50"), >+ [% CASE 'bulkmarkimport' %]'[% record_source %]': _("bulkmarcimport.pl"), >+ [% CASE 'import_lexile' %]'[% record_source %]': _("import_lexile.pl"), >+ [% CASE %] '[% record_source %]' : '[% record_source | html %]', >+ [% END %] >+ [% END %] > }, > > categorycode: categories, >-- >2.39.5
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 35380
:
175800
|
175801
| 175802 |
175803