Bugzilla – Attachment 161582 Details for
Bug 35919
Add record sources CRUD
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35919: Add Koha::Biblio::Metadata->can_be_edited
Bug-35919-Add-KohaBiblioMetadata-canbeedited.patch (text/plain), 2.45 KB, created by
Matt Blenkinsop
on 2024-01-29 10:35:46 UTC
(
hide
)
Description:
Bug 35919: Add Koha::Biblio::Metadata->can_be_edited
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-01-29 10:35:46 UTC
Size:
2.45 KB
patch
obsolete
>From 8ccf96e8ae83a835800aa0ad8d6cbd936b119ae8 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->can_be_edited > >prove t/db_dependent/Koha/Biblio/Metadata.t > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >--- > Koha/Biblio/Metadata.pm | 16 ++++++++++++++++ > t/db_dependent/Koha/Biblio/Metadata.t | 27 ++++++++++++++++++++++++++- > 2 files changed, 42 insertions(+), 1 deletion(-) > >diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm >index d5bfea5cd0..c78feac5c8 100644 >--- a/Koha/Biblio/Metadata.pm >+++ b/Koha/Biblio/Metadata.pm >@@ -170,6 +170,22 @@ sub record_strip_nonxml { > return $self->record( { %$params, record => $record } ); > } > >+=head3 can_be_edited >+ >+ if ( $metadata->can_be_edited ) { ... } >+ >+Returns a boolean denoting whether the metadata record can be edited. >+ >+=cut >+ >+sub can_be_edited { >+ 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 5318ebc23f..7efdf58035 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 'can_be_edited() 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->can_be_edited, '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->can_be_edited, 'Record source allows, can be edited' ); >+ >+ $source->can_be_edited(0)->store(); >+ $metadata->discard_changes; >+ >+ ok( !$metadata->can_be_edited, 'Record source does not allow, cannot be edited' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.37.1 (Apple Git-137.1)
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 35919
:
161531
|
161532
|
161533
|
161534
|
161535
|
161537
|
161538
|
161577
|
161578
|
161579
|
161580
|
161581
|
161582
|
161583
|
162489
|
162594
|
162595
|
162596
|
162599
|
163348
|
163349
|
163350
|
163351
|
163352
|
163353
|
163354
|
163355
|
163360
|
163369
|
163389
|
163390
|
163391
|
163392
|
163393
|
163394
|
163395
|
163396
|
163397
|
163398
|
163399
|
163400
|
164708
|
164709
|
164710
|
164711
|
164712
|
164713
|
164714
|
164715
|
164716
|
164717
|
165274