From 9768b687c0ce9b59e37546068c2362688d482f20 Mon Sep 17 00:00:00 2001 From: Moray Jones Date: Thu, 12 Sep 2024 17:05:41 +0100 Subject: [PATCH] [Bexley] Look up service description. Adds the service description to the report title, so it's e.g. included in the template email. https://mysocietysupport.freshdesk.com/a/tickets/4449 --- perllib/FixMyStreet/Cobrand/Bexley/Waste.pm | 15 ++++++++++----- t/app/controller/waste_bexley.t | 9 ++++++++- .../email/bexley/waste/_sidebar_content.html | 6 ++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm b/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm index 7ea80543dc2..f3618173edf 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm @@ -1091,18 +1091,23 @@ sub waste_munge_report_data { my $c = $self->{c}; - my $address = $c->stash->{property}->{address}; - my $service = $c->stash->{services}{$id}{service_name}; + my $property = $c->stash->{property}; + my $address = $property->{address}; + my $service_id = $c->stash->{services}{$id}{service_id}; + my $service_name = $c->stash->{services}{$id}{service_name}; my $uprn = $c->stash->{services}{$id}{uprn}; - $data->{title} = "Report missed $service"; + my $containers = $self->_containers($property); + my $service_description = $containers->{$service_id}->{description}; + $service_description = 'Various' if $service_description =~ /
  • /; + $data->{title} = "$service_name ($service_description)"; $data->{detail} = "$data->{title}\n\n$address"; $c->set_param('uprn', $uprn); $c->set_param('service_id', $id); $c->set_param('location_of_containers', $data->{extra_detail}) if $data->{extra_detail}; - $c->set_param('service_item_name', $c->stash->{services}{$id}{service_id}); + $c->set_param('service_item_name', $service_id); # Check if this property has assisted collections - my $contracts = $self->whitespace->GetSiteContracts($c->stash->{property}{uprn}); + my $contracts = $self->whitespace->GetSiteContracts($property->{uprn}); $c->set_param('assisted_yn', (grep { $_->{ContractID} == 7 } @$contracts) ? 'Yes' : 'No'); } diff --git a/t/app/controller/waste_bexley.t b/t/app/controller/waste_bexley.t index 7360d97b966..59963d31d6d 100644 --- a/t/app/controller/waste_bexley.t +++ b/t/app/controller/waste_bexley.t @@ -6,6 +6,7 @@ use Test::MockTime 'set_fixed_time'; use Test::Output; use FixMyStreet::TestMech; use FixMyStreet::Script::Reports; +use FixMyStreet::Script::Alerts; FixMyStreet::App->log->disable('info'); END { FixMyStreet::App->log->enable('info'); } @@ -846,7 +847,13 @@ FixMyStreet::override_config { 'Submitting missed collection report' ); $mech->content_contains('Missed collection has been reported'); - + FixMyStreet::Script::Reports::send(); + my @emails = $mech->get_email; + my $email; + for my $mail (@emails) { + $email = $mail->as_string if $mail->header('To') =~ 'test@example.com'; + }; + like $email, qr/Brown Caddy \(Food waste\)/, 'Service added to title'; my @reports = FixMyStreet::DB->resultset("Problem")->all; is @reports, 1, 'only one report created'; diff --git a/templates/email/bexley/waste/_sidebar_content.html b/templates/email/bexley/waste/_sidebar_content.html index ff0ae715e72..2a4aaa5e024 100644 --- a/templates/email/bexley/waste/_sidebar_content.html +++ b/templates/email/bexley/waste/_sidebar_content.html @@ -1,16 +1,14 @@ [% # Hacky string munging :-( %] +[% containers = cobrand.container_desc_for_template %] [% address = report.get_extra_metadata.property_address; IF is_no_collections_enquiry; title = report.detail; title = title.remove(address); - ELSIF is_missed_collection; - title = report.title; - title = title.remove('Report missed '); END %]

    Bins reported as missed:

    -[% title | html_para_email(secondary_p_style) %] +[% report.title | html_para_email(secondary_p_style) %]

    Address:

    [% address | html_para_email(secondary_p_style) %]