Bugzilla – Attachment 137522 Details for
Bug 12029
Patrons should be able to delete their patron messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12029: (follow-up) Adhering to coding guidelines
Bug-12029-follow-up-Adhering-to-coding-guidelines.patch (text/plain), 7.58 KB, created by
Martin Renvoize (ashimema)
on 2022-07-11 14:58:15 UTC
(
hide
)
Description:
Bug 12029: (follow-up) Adhering to coding guidelines
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-07-11 14:58:15 UTC
Size:
7.58 KB
patch
obsolete
>From 06ba191d1651e9365a17e02c86aff2b9c67488ca Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Fri, 8 Jul 2022 18:42:59 +0000 >Subject: [PATCH] Bug 12029: (follow-up) Adhering to coding guidelines > >This is a follow-up patch which (based on comment #19) does >the following: > >1) Removes newline from top of Koha/Patron/Messages.pm >2) Changes method Koha::Patron::Messages->unread to ->filter_by_unread >3) Removes method Koha::Patron::Messages->unread_count >4) (Will address tests in separate patch) >5) Removes changes to Koha/Schema/Result/Message.pm >6) Changes atomicupdate from qq{} to q{} >7) (Left for RM) >8) Removes extra copyright statement in opac/dismiss_message.pl >9) Removes extra comments from opac/dismiss_message.pl >10) (Left for now) >11) (Left for now) > >Sponsored-by: Horowhenua Library Trust >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron/Messages.pm | 18 ++---------------- > installer/data/mysql/atomicupdate/bug_12029.pl | 2 +- > .../bootstrap/en/includes/opac-note.inc | 4 ++-- > .../bootstrap/en/modules/opac-main.tt | 6 +++--- > opac/dismiss_message.pl | 5 +++-- > t/db_dependent/Koha/Patron/Messages.t | 12 ++++++------ > 6 files changed, 17 insertions(+), 30 deletions(-) > >diff --git a/Koha/Patron/Messages.pm b/Koha/Patron/Messages.pm >index 33eb7d6901..d0acf6bceb 100644 >--- a/Koha/Patron/Messages.pm >+++ b/Koha/Patron/Messages.pm >@@ -50,13 +50,13 @@ sub object_class { > return 'Koha::Patron::Message'; > } > >-=head3 unread >+=head3 filter_by_unread > > Returns a result set of messages that haven't been marked read by the patron > > =cut > >-sub unread { >+sub filter_by_unread { > # return resultset of messages with an undefined patron_read_date > my ($self, $params) = @_; > $params ||= {}; >@@ -65,18 +65,4 @@ sub unread { > %$params, > }); > } >- >-=head3 unread_count >- >- Returns a count of messages that haven't been marked read by the patron >- >-=cut >- >- >-sub unread_count { >- # return count of unread >- my ($self, $params) = @_; >- $params ||= {}; >- return $self->unread(%$params)->count(); >-} > 1; >diff --git a/installer/data/mysql/atomicupdate/bug_12029.pl b/installer/data/mysql/atomicupdate/bug_12029.pl >index f352a66edf..5637d6b658 100755 >--- a/installer/data/mysql/atomicupdate/bug_12029.pl >+++ b/installer/data/mysql/atomicupdate/bug_12029.pl >@@ -8,7 +8,7 @@ return { > my ($dbh, $out) = @$args{qw(dbh out)}; > > # Do you stuffs here >- my $alteration = qq{ >+ my $alteration = q{ > ALTER TABLE messages > ADD COLUMN `patron_read_date` timestamp NULL DEFAULT NULL > COMMENT 'date and time patron dismissed message' >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc >index 8b2c39f861..bae94785ea 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc >@@ -1,8 +1,8 @@ >-[% IF patron_messages.unread_count OR opacnote %] >+[% IF patron_messages.filter_by_unread.count OR opacnote %] > <div class="alert alert-info"> > <h3>Messages for you</h3> > <ul> >- [% FOREACH message IN patron_messages.unread %] >+ [% FOREACH message IN patron_messages.filter_by_unread %] > <li> > <strong>[% message.message | html | html_line_break %]</strong><br> > <em>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) | html %]</em> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >index cd679226cb..7786169d32 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -263,7 +263,7 @@ > </a> > </li> > [% END %] >- [% IF patron_messages && patron_messages.unread_count || opacnote %] >+ [% IF patron_messages && patron_messages.filter_by_unread.count || opacnote %] > [% IF opacnote %] > <li> > <a href="/cgi-bin/koha/opac-user.pl"> >@@ -274,8 +274,8 @@ > [% ELSE %] > <li> > <a href="/cgi-bin/koha/opac-user.pl"> >- <span class="count_label">[% patron_messages.unread_count | html %]</span> >- [% tn('message', 'messages', patron_messages.unread_count ) | html %] >+ <span class="count_label">[% patron_messages.filter_by_unread.count | html %]</span> >+ [% tn('message', 'messages', patron_messages.filter_by_unread.count ) | html %] > </a> > </li> > [% END %] >diff --git a/opac/dismiss_message.pl b/opac/dismiss_message.pl >index 6497060860..5c1344921e 100755 >--- a/opac/dismiss_message.pl >+++ b/opac/dismiss_message.pl >@@ -1,7 +1,8 @@ > #!/usr/bin/perl >-# This file is part of Koha. >-# > # Copyright (C) 2022 Auto-Parallel Technologies, Inc. >+ >+# >+# 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 >diff --git a/t/db_dependent/Koha/Patron/Messages.t b/t/db_dependent/Koha/Patron/Messages.t >index 262d89b019..5077ab3dcc 100755 >--- a/t/db_dependent/Koha/Patron/Messages.t >+++ b/t/db_dependent/Koha/Patron/Messages.t >@@ -100,7 +100,7 @@ is( Koha::Patron::Messages->search->count, $nb_of_messages + 1, 'Delete should h > is( get_nb_of_logactions(), $nb_of_logaction + 3, 'With BorrowersLog on, 1 new log should have been added when deleting a new message' ); > > # START BUG-12029 >-my $starting_unread_count = Koha::Patron::Messages->unread_count(); >+my $starting_unread_count = Koha::Patron::Messages->filter_by_unread()->count(); > > my $new_message_4 = Koha::Patron::Message->new( > { >@@ -113,17 +113,17 @@ my $new_message_4 = Koha::Patron::Message->new( > )->store; > > is( >- Koha::Patron::Messages->unread_count(), >+ Koha::Patron::Messages->filter_by_unread()->count(), > $starting_unread_count + 1, > "Unread count should return a new count one higher" > ); > is( >- Koha::Patron::Messages->unread->count(), >+ Koha::Patron::Messages->filter_by_unread()->count(), > $starting_unread_count + 1, > "Unread should be able to have count called on it and return the same number" > ); > >-ok( ( grep { $_->message eq $new_message_4->message } @{ Koha::Patron::Messages->unread->as_list } ), >+ok( ( grep { $_->message eq $new_message_4->message } @{ Koha::Patron::Messages->filter_by_unread()->as_list() } ), > "Unread should return our new_message_4" ); > > # Set a message to be read >@@ -133,8 +133,8 @@ $new_message_4->update( > } > ); > >-is( Koha::Patron::Messages->unread_count(), >- $starting_unread_count, "Unread count should return the original count of messages" ); >+is( Koha::Patron::Messages->filter_by_unread()->count(), >+ $starting_unread_count, "Unread count should return the original count of messages (run dbic if this fails)." ); > # END BUG-12029 > > >-- >2.20.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 12029
:
130514
|
130515
|
130516
|
132918
|
132949
|
137434
|
137435
|
137518
|
137519
|
137520
|
137521
|
137522
|
137523
|
137646
|
137647
|
137648
|
146706
|
146707
|
146708
|
146709
|
147521
|
147522
|
147523
|
147524
|
147525
|
148607
|
148608
|
148609
|
148610
|
148611