Bugzilla – Attachment 130044 Details for
Bug 29230
Patron's messages not accessible from template notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29230: Add Koha::Patron->messages
Bug-29230-Add-KohaPatron-messages.patch (text/plain), 4.35 KB, created by
Jonathan Druart
on 2022-02-01 14:40:43 UTC
(
hide
)
Description:
Bug 29230: Add Koha::Patron->messages
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-01 14:40:43 UTC
Size:
4.35 KB
patch
obsolete
>From ab6783310a35a4d6a883d4780c84e3d320203039 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Oct 2021 09:57:38 +0200 >Subject: [PATCH] Bug 29230: Add Koha::Patron->messages > >Add methods to return the messages attached to a patron. > >It will add the capability to access them from notice templates. > >Test plan: >Define some messages for a given patron >Go to the circulation page of the patron and confirm that they are still >displayed > >Test the notice templates: >Add to HOLD_SLIP the following content >""" >[% SET messages = borrower.messages %] >[% IF messages.count %] >Messages: ><ul> > [% FOR m IN messages.search( message_type => 'L' ) %] > <li>[% m.message %]</li> > [% END %] ></ul> >[% END %] >""" > >To display all the messages from staff ('L') > >Adapt following your needs. > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> > >Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se> >--- > Koha/Patron.pm | 15 +++++++++++++++ > circ/circulation.pl | 9 +++------ > t/db_dependent/Koha/Patron.t | 31 ++++++++++++++++++++++++++++++- > 3 files changed, 48 insertions(+), 7 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index ddf4ebe5bbb..d0c0caf3971 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -44,6 +44,7 @@ use Koha::Patron::Debarments; > use Koha::Patron::HouseboundProfile; > use Koha::Patron::HouseboundRole; > use Koha::Patron::Images; >+use Koha::Patron::Messages; > use Koha::Patron::Modifications; > use Koha::Patron::Relationships; > use Koha::Patrons; >@@ -1710,6 +1711,20 @@ sub extended_attributes { > return Koha::Patron::Attributes->_new_from_dbic($rs)->search; > } > >+=head3 messages >+ >+ my $messages = $patron->messages; >+ >+Return the message attached to the patron. >+ >+=cut >+ >+sub messages { >+ my ( $self ) = @_; >+ my $messages_rs = $self->_result->messages_borrowernumbers->search; >+ return Koha::Patron::Messages->_new_from_dbic($messages_rs); >+} >+ > =head3 lock > > Koha::Patrons->find($id)->lock({ expire => 1, remove => 1 }); >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 705ac45ac5b..4aedccb24cc 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -51,7 +51,6 @@ use Koha::Plugins; > use Koha::Database; > use Koha::BiblioFrameworks; > use Koha::Items; >-use Koha::Patron::Messages; > use Koha::SearchEngine; > use Koha::SearchEngine::Search; > use Koha::Patron::Modifications; >@@ -523,10 +522,8 @@ if ( $patron ) { > } > } > >-my $patron_messages = Koha::Patron::Messages->search( >- { >- 'me.borrowernumber' => $borrowernumber, >- }, >+my $patron_messages = $patron->messages->search( >+ {}, > { > join => 'manager', > '+select' => ['manager.surname', 'manager.firstname' ], >@@ -579,7 +576,7 @@ if ($restoreduedatespec || $stickyduedate) { > } > > $template->param( >- patron_messages => $patron_messages, >+ patron_messages => $patron_messages, > borrowernumber => $borrowernumber, > branch => $branch, > was_renewed => scalar $query->param('was_renewed') ? 1 : 0, >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index ce114cab0ee..e7a60c0a248 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use Test::Exception; > use Test::Warn; > >@@ -1021,3 +1021,32 @@ subtest 'add_article_request_fee_if_needed() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'messages' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $messages = $patron->messages; >+ is( $messages->count, 0, "No message yet" ); >+ my $message_1 = $builder->build_object( >+ { >+ class => 'Koha::Patron::Messages', >+ value => { borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ my $message_2 = $builder->build_object( >+ { >+ class => 'Koha::Patron::Messages', >+ value => { borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ >+ $messages = $patron->messages; >+ is( $messages->count, 2, "There are two messages for this patron" ); >+ is( $messages->next->message, $message_1->message ); >+ is( $messages->next->message, $message_2->message ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.25.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 29230
:
126641
|
127678
|
128162
|
130044
|
130097