Bug 30076

Summary: Add ability to check patron messaging preferences from a notice
Product: Koha Reporter: Kyle M Hall <kyle>
Component: Architecture, internals, and plumbingAssignee: Kyle M Hall <kyle>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, fridolin.somers, lucas
Version: MainKeywords: Manual
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement gives notices access to a patron's messaging preferences. For example, a hold slip could contain a line if the patron has requested SMS notifications for waiting holds, or perhaps phone notifications. The format for this new method is as follows: [% patron.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'email' }) %]
Version(s) released in:
22.05.00
Attachments: Bug 30076: Add ability to check patron messaging preferences from a notice
Bug 30076: Add ability to check patron messaging preferences from a notice
Bug 30076: Add ability to check patron messaging preferences from a notice
Bug 30076: Add ability to check patron messaging preferences from a notice
Bug 30076: Add ability to check patron messaging preferences from a notice

Description Kyle M Hall 2022-02-10 17:18:54 UTC
Some libraries want to be able to use a patron's messaging preferences to conditionally change the contents of a notice depending on the patron's other messaging preference. For example, a library has requested to have the note on the hold slip if the patron has requested phone messages for waiting holds. This really only entails adding a method to the Koha::Patron class to allow this type of looking.
Comment 1 Kyle M Hall 2022-02-10 17:23:14 UTC
Created attachment 130458 [details] [review]
Bug 30076: Add ability to check patron messaging preferences from a notice

Some libraries want to be able to use a patron's messaging preferences to conditionally change the contents of a notice depending on the patron's other messaging preference. For example, a library has requested to have the note on the hold slip if the patron has requested phone messages for waiting holds. This really only entails adding a method to the Koha::Patron class to allow this type of looking.

Test plan:
1) Apply this patch
2) Enable item checkout notices for a patron for email, but not sms
3) Include the following in the notice:
   TEST1: [% patron.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'email' }) %]
   <br/>
   TEST2: [% patron.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'sms' }) %]
4) Generate a checkout and notice for that patron
5) Note the generated notice has a 1 for TEST1, but not for TEST2
Comment 2 Kyle M Hall 2022-02-10 18:47:42 UTC
Created attachment 130459 [details] [review]
Bug 30076: Add ability to check patron messaging preferences from a notice

Some libraries want to be able to use a patron's messaging preferences to conditionally change the contents of a notice depending on the patron's other messaging preference. For example, a library has requested to have the note on the hold slip if the patron has requested phone messages for waiting holds. This really only entails adding a method to the Koha::Patron class to allow this type of looking.

Test plan:
1) Apply this patch
2) Enable item checkout notices for a patron for email, but not sms
3) Include the following in the notice:
   TEST1: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'email' }) %]
   <br/>
   TEST2: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'sms' }) %]
4) Generate a checkout and notice for that patron
5) Note the generated notice has a 1 for TEST1, but not for TEST2
Comment 3 Lucas Gass 2022-02-10 19:03:58 UTC
Created attachment 130468 [details] [review]
Bug 30076: Add ability to check patron messaging preferences from a notice

Some libraries want to be able to use a patron's messaging preferences to conditionally change the contents of a notice depending on the patron's other messaging preference. For example, a library has requested to have the note on the hold slip if the patron has requested phone messages for waiting holds. This really only entails adding a method to the Koha::Patron class to allow this type of looking.

Test plan:
1) Apply this patch
2) Enable item checkout notices for a patron for email, but not sms
3) Include the following in the notice:
   TEST1: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'email' }) %]
   <br/>
   TEST2: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'sms' }) %]
4) Generate a checkout and notice for that patron
5) Note the generated notice has a 1 for TEST1, but not for TEST2

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Lucas Gass 2022-02-10 19:07:45 UTC
This is cool. It also works well in other notices with different message_names. I tried:

Hold_filled 	
Item_check-in 	
Item_checkout 	
Auto_renewal 				
Hold_reminder

Tested in these notices:

CHECKOUT
CHECKIN
HOLD_SLIP
Comment 5 Katrin Fischer 2022-03-27 12:35:52 UTC
It looks like the recalls code interfered here a bit, possibly an easy fix:

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 30076: Add ability to check patron messaging preferences from a notice
Using index info to reconstruct a base tree...
M	Koha/Patron.pm
Falling back to patching base and 3-way merge...
Auto-merging Koha/Patron.pm
CONFLICT (content): Merge conflict in Koha/Patron.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 30076: Add ability to check patron messaging preferences from a notice
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-30076-Add-ability-to-check-patron-messaging-pr-Kjd5sQ.patch

My only other concern here would be documentation. Maybe we could at least at a note about this to the wiki pages for TT notices for now, so we got a starting point for more/better documentation later.
Comment 6 Kyle M Hall 2022-03-28 12:24:46 UTC
Created attachment 132324 [details] [review]
Bug 30076: Add ability to check patron messaging preferences from a notice

Some libraries want to be able to use a patron's messaging preferences to conditionally change the contents of a notice depending on the patron's other messaging preference. For example, a library has requested to have the note on the hold slip if the patron has requested phone messages for waiting holds. This really only entails adding a method to the Koha::Patron class to allow this type of looking.

Test plan:
1) Apply this patch
2) Enable item checkout notices for a patron for email, but not sms
3) Include the following in the notice:
   TEST1: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'email' }) %]
   <br/>
   TEST2: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'sms' }) %]
4) Generate a checkout and notice for that patron
5) Note the generated notice has a 1 for TEST1, but not for TEST2

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 7 Katrin Fischer 2022-03-28 22:21:54 UTC
Created attachment 132374 [details] [review]
Bug 30076: Add ability to check patron messaging preferences from a notice

Some libraries want to be able to use a patron's messaging preferences to conditionally change the contents of a notice depending on the patron's other messaging preference. For example, a library has requested to have the note on the hold slip if the patron has requested phone messages for waiting holds. This really only entails adding a method to the Koha::Patron class to allow this type of looking.

Test plan:
1) Apply this patch
2) Enable item checkout notices for a patron for email, but not sms
3) Include the following in the notice:
   TEST1: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'email' }) %]
   <br/>
   TEST2: [% borrower.has_messaging_preference({ message_name => 'Item_Checkout', message_transport_type => 'sms' }) %]
4) Generate a checkout and notice for that patron
5) Note the generated notice has a 1 for TEST1, but not for TEST2

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Fridolin Somers 2022-04-08 10:16:20 UTC
Great :)
This can be useful in other places
Comment 9 Fridolin Somers 2022-04-08 13:53:23 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄