Bugzilla – Attachment 163428 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 TT plugin method Biblio.CanBeEdited
Bug-31791-Add-TT-plugin-method-BiblioCanBeEdited.patch (text/plain), 3.05 KB, created by
Martin Renvoize (ashimema)
on 2024-03-19 14:13:26 UTC
(
hide
)
Description:
Bug 31791: Add TT plugin method Biblio.CanBeEdited
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-03-19 14:13:26 UTC
Size:
3.05 KB
patch
obsolete
>From ace265711d4817686a1d8291fb8cf558e6c93f97 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 2 Feb 2024 16:25:41 -0300 >Subject: [PATCH] Bug 31791: Add TT plugin method Biblio.CanBeEdited > >Sponsored-by: ByWater Solutions >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Template/Plugin/Biblio.pm | 6 +++ > t/db_dependent/Template/Plugin/Biblio.t | 68 +++++++++++++++++++++++++ > 2 files changed, 74 insertions(+) > create mode 100755 t/db_dependent/Template/Plugin/Biblio.t > >diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm >index e339263b9c9..f0a3dd9f0fd 100644 >--- a/Koha/Template/Plugin/Biblio.pm >+++ b/Koha/Template/Plugin/Biblio.pm >@@ -69,4 +69,10 @@ sub RecallsCount { > return $recalls->count; > } > >+sub CanBeEdited { >+ my ( $self, $biblio, $patron ) = @_; >+ >+ return $biblio->can_be_edited($patron); >+} >+ > 1; >diff --git a/t/db_dependent/Template/Plugin/Biblio.t b/t/db_dependent/Template/Plugin/Biblio.t >new file mode 100755 >index 00000000000..368ff0d02c5 >--- /dev/null >+++ b/t/db_dependent/Template/Plugin/Biblio.t >@@ -0,0 +1,68 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+use Test::MockModule; >+ >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+BEGIN { >+ use_ok('Koha::Template::Plugin::Biblio'); >+} >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'CanBeEdited() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $can_be_edited; >+ >+ my $mock_biblio = Test::MockModule->new('Koha::Biblio'); >+ $mock_biblio->mock( 'can_be_edited', sub { return $can_be_edited; } ); >+ >+ my $plugin = Koha::Template::Plugin::Biblio->new(); >+ >+ $can_be_edited = undef; >+ is( >+ $plugin->CanBeEdited( $biblio, $patron ), undef, >+ 'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' >+ ); >+ >+ $can_be_edited = 0; >+ is( >+ $plugin->CanBeEdited( $biblio, $patron ), 0, >+ 'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' >+ ); >+ >+ $can_be_edited = 1; >+ is( >+ $plugin->CanBeEdited( $biblio, $patron ), 1, >+ 'CanBeEdited is just a wrapper around Koha::Biblio->can_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