Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Peterborough][WW] Add text messaging option for bulky waste #4887

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

MorayMySoc
Copy link
Contributor

@MorayMySoc MorayMySoc commented Mar 15, 2024

Adds text box to opt into text updates for bulky waste bookings.

Allows multiple govuk_notify templates/keys to be added in array

https://github.com/mysociety/societyworks/issues/3782

[skip changelog]

@MorayMySoc MorayMySoc requested a review from davea March 15, 2024 11:48
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.61%. Comparing base (399a997) to head (fdf0144).
Report is 546 commits behind head on master.

Files with missing lines Patch % Lines
perllib/FixMyStreet/Cobrand/UKCouncils.pm 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4887      +/-   ##
==========================================
+ Coverage   82.57%   82.61%   +0.04%     
==========================================
  Files         393      393              
  Lines       30697    30726      +29     
  Branches     4861     4869       +8     
==========================================
+ Hits        25347    25385      +38     
+ Misses       3898     3892       -6     
+ Partials     1452     1449       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@davea davea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally this is nearly there, but I've made a few comments about ways the code could be improved/tidied up a bit.

Comment on lines 1320 to 1329
sprintf("%s\n\n
Date: %s
Items: %d
%s
View more details or cancel: %s",
$title,
$self->bulky_nice_collection_date($report->get_extra_field_value('DATE')),
scalar grep ({ $_->{name} =~ /^ITEM/ && $_->{value} } @{$report->get_extra_fields}),
$address,
$h->{url});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent this.

@@ -344,6 +344,9 @@ sub _add_confirmed_update {
sub _send_report_sent_email {
my $self = shift;

if ($self->report->get_extra_field_value('bulky_text_updates')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this instead live in Peterborough::post_report_sent or Peterborough::open311_post_send perhaps? It'd be nice to keep cobrand-specific bits out of here if possible.

title => 'About you',
next => 'choose_date_earlier',
update_field_list => sub {
my $form = shift;
if ($form->c->cobrand->moniker eq 'peterborough') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have a COBRAND_FEATURES flag for the new feature rather than hardcoding the peterborough check everywhere. This would make it easier to roll out to other cobrands later and also means we can turn it on/off for Peterborough with a redeploy rather than code changes.

@@ -552,10 +552,14 @@ sub bulky_reminders {
sub _bulky_send_reminder_email {
my ($self, $report, $h, $params) = @_;

return unless $report->user->email;
return unless $report->user->email || $report->get_extra_field_value('bulky_text_updates');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside a function called _bulky_send_reminder_email so shouldn't have anything to do with sending texts - can you factor this (and the below call_hook lines) into a new _bulky_send_reminder_text function which gets called independently?

@@ -64,6 +66,7 @@ create_contact(
{ code => 'payment' },
{ code => 'payment_method' },
{ code => 'property_id' },
{ code => 'bulky_text_updates' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably me not paying close enough attention but it took me ages of wondering why the feature wasn't working before I spotted this line and realised I also needed to add a bulky_text_updates hidden field to my existing Bulky collection category. Always helpful to please include notes for the reviewer when adding code that needs configuration/changes beyond checking out the branch.

unless $email->is_inactive || $email->value || ($is_staff_user && !$staff_provide_email);

unless $email->is_inactive || $email->value || ($is_staff_user && !$staff_provide_email)
|| (FixMyStreet::SMS->parse_username($phone->value)->{may_be_mobile} && $cobrand eq 'peterborough');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems to make the email address optional on the "About you" page if I provide a mobile number, but I can't complete a booking without an email address:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to this in ba1e015 May need more discussion...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that fix has had the desired effect - if bulky_offer_text_updates isn't present in waste_features this still allows the user to omit their email address on the "about you" page and they'll still see the above error when trying to go to the payment screen.

@@ -62,6 +62,14 @@ has_field email => (
},
);

has_field extra_bulky_text_updates => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording here isn't very clear, what about something like:
image

@MorayMySoc MorayMySoc requested a review from davea March 20, 2024 14:37
@@ -62,6 +62,14 @@ has_field email => (
},
);

has_field extra_bulky_text_updates => (
type => 'Checkbox',
label => 'Bulky text updates',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think the inclusion of 'updates' here is misleading as the message aren't really updates - they're reminders.

unless $email->is_inactive || $email->value || ($is_staff_user && !$staff_provide_email);

unless $email->is_inactive || $email->value || ($is_staff_user && !$staff_provide_email)
|| (FixMyStreet::SMS->parse_username($phone->value)->{may_be_mobile} && $cobrand eq 'peterborough');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that fix has had the desired effect - if bulky_offer_text_updates isn't present in waste_features this still allows the user to omit their email address on the "about you" page and they'll still see the above error when trying to go to the payment screen.

@MorayMySoc MorayMySoc requested a review from davea April 5, 2024 14:18
MorayMySoc added 13 commits May 17, 2024 11:01
Adds text message request checkout to bulky waste details page
that is active only for Peterborough

mysociety/societyworks#3782
Checks if govuk_notify is an array which will contain
hashes that now include type.

If the config is not an array continues as previously,
otherwise will choose which config to use based on
data assigned to notify_choice

Related to mysociety/societyworks#3782
If the user chose to receive updates by phone when making their
bulky waste booking, send text updates for 3 and 1 day reminders.

Continue to send emails if there is an email address.

mysociety/societyworks#3782
If the user has elected to receive optional texts for updates
to their booking, they will be sent a text when the bulky
booking is confirmed.

Normal email confirmation also takes place.

mysociety/societyworks#3782
Adds tests for optional text messaging for Bulky waste bookings

mysociety/societyworks#3782
Renaming to be clearer about what it's for which is for
sending reminders about bulky waste collections which
have been ordered.
@mysociety-pusher mysociety-pusher force-pushed the 3782-peterborough-bulky-text-messaging branch from 2932a18 to cea77c2 Compare May 17, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants