Bugzilla – Attachment 161441 Details for
Bug 32607
Add record sources CRUD
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32607: Add Koha::Biblio::Metadata->can_be_edited
Bug-32607-Add-KohaBiblioMetadata-canbeedited.patch (text/plain), 2.88 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-01-25 15:45:05 UTC
(
hide
)
Description:
Bug 32607: Add Koha::Biblio::Metadata->can_be_edited
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-01-25 15:45:05 UTC
Size:
2.88 KB
patch
obsolete
>From 4b25c0b747936a97c054f16bcaa9e5e9a132d73b 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 32607: Add Koha::Biblio::Metadata->can_be_edited > >--- > Koha/Biblio/Metadata.pm | 16 ++++++++++++ > t/cypress/integration/RecordSources_spec.ts | 2 +- > t/db_dependent/Koha/Biblio/Metadata.t | 27 ++++++++++++++++++++- > 3 files changed, 43 insertions(+), 2 deletions(-) > >diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm >index d5bfea5cd00..c78feac5c8d 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/cypress/integration/RecordSources_spec.ts b/t/cypress/integration/RecordSources_spec.ts >index 6775083e0dd..54be8ece229 100644 >--- a/t/cypress/integration/RecordSources_spec.ts >+++ b/t/cypress/integration/RecordSources_spec.ts >@@ -41,7 +41,7 @@ describe("Record sources CRUD tests", () => { > // Submit the form, get 500 > cy.intercept("POST", "/api/v1/record_sources", { > statusCode: 201, >- body: {} >+ body: {}, > }); > cy.get("#record_source_edit").contains("Submit").click(); > }); >diff --git a/t/db_dependent/Koha/Biblio/Metadata.t b/t/db_dependent/Koha/Biblio/Metadata.t >index 5318ebc23f8..7efdf580359 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.43.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 32607
:
146410
|
146411
|
146412
|
149777
|
149827
|
149828
|
149829
|
154006
|
154007
|
154008
|
154009
|
154010
|
154438
|
155682
|
155683
|
155684
|
155685
|
155686
|
155958
|
157756
|
157757
|
157758
|
157759
|
157760
|
157761
|
157762
|
161362
|
161363
|
161364
|
161365
|
161366
|
161367
|
161435
|
161436
|
161437
|
161438
|
161439
|
161440
| 161441 |
161474