Bugzilla – Attachment 164195 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 31791: Add Koha::Biblio::Metadata->record_source
Bug-31791-Add-KohaBiblioMetadata-recordsource.patch (text/plain), 2.90 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-04-01 14:47:03 UTC
(
hide
)
Description:
Bug 31791: Add Koha::Biblio::Metadata->record_source
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-04-01 14:47:03 UTC
Size:
2.90 KB
patch
obsolete
>From fa51a591201fe1ffa2829c80b50d1e0eb75e15a3 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 20 Mar 2024 09:50:39 -0300 >Subject: [PATCH] Bug 31791: Add Koha::Biblio::Metadata->record_source > >This patch adds a method for retrieving the related *Koha::RecordSource* from a *Koha::Biblio::Metadata* object. > >The method is covered by tests: > >1. Apply this patch >2. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/Biblio/Metadata.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Sponsored-by: ByWater Solutions >--- > Koha/Biblio/Metadata.pm | 18 ++++++++++++++++++ > t/db_dependent/Koha/Biblio/Metadata.t | 9 +++++++-- > 2 files changed, 25 insertions(+), 2 deletions(-) > >diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm >index 926beda2c56..1b6854f0bf4 100644 >--- a/Koha/Biblio/Metadata.pm >+++ b/Koha/Biblio/Metadata.pm >@@ -23,8 +23,10 @@ use Scalar::Util qw( blessed ); > use C4::Biblio qw( GetMarcFromKohaField ); > use C4::Charset qw( StripNonXmlChars ); > use C4::Items qw( GetMarcItem ); >+ > use Koha::Database; > use Koha::Exceptions::Metadata; >+use Koha::RecordSources; > > use base qw(Koha::Object); > >@@ -187,6 +189,22 @@ sub source_allows_editing { > return $rs->can_be_edited; > } > >+=head3 record_source >+ >+ my $record_source = $metadata->record_source; >+ >+Returns a I<Koha::RecordSource> object for the linked record source. >+ >+=cut >+ >+sub record_source { >+ my ($self) = @_; >+ >+ my $rs = $self->_result->record_source; >+ return unless $rs; >+ return Koha::RecordSource->_new_from_dbic($rs); >+} >+ > =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 7a459938615..172fd2bb041 100755 >--- a/t/db_dependent/Koha/Biblio/Metadata.t >+++ b/t/db_dependent/Koha/Biblio/Metadata.t >@@ -267,9 +267,9 @@ subtest '_embed_items' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'source_allows_editing() tests' => sub { >+subtest 'record_source() and source_allows_editing() tests' => sub { > >- plan tests => 4; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -278,11 +278,16 @@ subtest 'source_allows_editing() tests' => sub { > 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' ); >+ is( $metadata->record_source, undef ); > > my $source = $builder->build_object( { class => 'Koha::RecordSources', value => { can_be_edited => 1 } } ); > $metadata->record_source_id( $source->id )->store(); > >+ my $retrieved_source = $metadata->record_source; >+ > ok( $metadata->source_allows_editing, 'Record source allows, can be edited' ); >+ is( ref($retrieved_source), 'Koha::RecordSource' ); >+ is( $retrieved_source->id, $source->id ); > > $source->can_be_edited(0)->store(); > $metadata->discard_changes; >-- >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