Bugzilla – Attachment 163371 Details for
Bug 31791
Add the ability to lock records to prevent modification through the Koha staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35919: Add Koha::Biblio::Metadata->source_allows_editing
Bug-35919-Add-KohaBiblioMetadata-sourceallowsediti.patch (text/plain), 2.73 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-03-18 20:30:16 UTC
(
hide
)
Description:
Bug 35919: Add Koha::Biblio::Metadata->source_allows_editing
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-03-18 20:30:16 UTC
Size:
2.73 KB
patch
obsolete
>From a2babdad34c2fa9023b45b7c170c4c41f41e2837 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 25 Jan 2024 12:29:37 -0300 >Subject: [PATCH] Bug 35919: Add Koha::Biblio::Metadata->source_allows_editing > >This patch adds a convenient method that tells if the record is >editable, according to it's record source. > >To test: >1. Apply this patch >2. Run: > $ ktd > k$ prove t/db_dependent/Koha/Biblio/Metadata.t >=> SUCCESS: Tests pass! Use cases covered! >3. Sign off :-D > >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> > >Bug 31791: Rename can_be_edited -> source_allows_editing >--- > Koha/Biblio/Metadata.pm | 17 +++++++++++++++++ > t/db_dependent/Koha/Biblio/Metadata.t | 27 ++++++++++++++++++++++++++- > 2 files changed, 43 insertions(+), 1 deletion(-) > >diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm >index d5bfea5cd00..926beda2c56 100644 >--- a/Koha/Biblio/Metadata.pm >+++ b/Koha/Biblio/Metadata.pm >@@ -170,6 +170,23 @@ sub record_strip_nonxml { > return $self->record( { %$params, record => $record } ); > } > >+=head3 source_allows_editing >+ >+ if ( $metadata->source_allows_editing ) { ... } >+ >+Returns a boolean denoting whether the metadata's record source allows >+it to be edited. >+ >+=cut >+ >+sub source_allows_editing { >+ my ($self) = @_; >+ >+ my $rs = $self->_result->record_source; >+ return 1 unless $rs; >+ return $rs->can_be_edited; >+} >+ > =head2 Internal methods > > =head3 _embed_items >diff --git a/t/db_dependent/Koha/Biblio/Metadata.t b/t/db_dependent/Koha/Biblio/Metadata.t >index 5318ebc23f8..7a459938615 100755 >--- a/t/db_dependent/Koha/Biblio/Metadata.t >+++ b/t/db_dependent/Koha/Biblio/Metadata.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::Exception; > use Test::Warn; > >@@ -266,3 +266,28 @@ subtest '_embed_items' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'source_allows_editing() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $metadata = $biblio->metadata; >+ is( $metadata->record_source_id, undef, 'No record source defined for metatada object' ); >+ ok( $metadata->source_allows_editing, 'No record source, can be edited' ); >+ >+ my $source = $builder->build_object( { class => 'Koha::RecordSources', value => { can_be_edited => 1 } } ); >+ $metadata->record_source_id( $source->id )->store(); >+ >+ ok( $metadata->source_allows_editing, 'Record source allows, can be edited' ); >+ >+ $source->can_be_edited(0)->store(); >+ $metadata->discard_changes; >+ >+ ok( !$metadata->source_allows_editing, 'Record source does not allow, cannot be edited' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.44.0
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 31791
:
163371
|
163372
|
163373
|
163374
|
163375
|
163376
|
163377
|
163378
|
163405
|
163408
|
163410
|
163411
|
163413
|
163414
|
163415
|
163416
|
163426
|
163427
|
163428
|
163429
|
163430
|
163431
|
163432
|
163433
|
163434
|
163531
|
163532
|
163533
|
163534
|
163535
|
163536
|
163537
|
163538
|
163539
|
163545
|
164193
|
164194
|
164195
|
164196
|
164197
|
164696
|
164697
|
164698
|
164699
|
164700
|
164701
|
164702
|
164703
|
164704
|
164705
|
165044
|
165045
|
165046
|
165047
|
165048
|
165049
|
165050
|
165051
|
165052
|
165053
|
165697