From b5b3b8e3cee367a8f82b4179a5d03f4d30e1215e Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 15 Jun 2016 12:02:53 +0100 Subject: [UK Councils] Send correct confirm emails for updates Some UK councils with Open311 integrations (e.g. Bromley) have a custom wording in the confirmation email sent when updates are left on reports, to make the user aware that the update is sent to the council in question. Bromley noticed that some emails were being sent without this wording, leading at least one user to contact the council directly about the report. It turns out that although the email template contains an IF clause to use the appropriate wording for Bromley (and Stevenage) reports, the incorrect template file was being used when updates were made via the Bromley cobrand. This commit solves the problem by introducing a new `Cobrand::Default::path_to_email_templates` method, which is overridden by `Cobrand::UKCouncils` to include the `templates/email/fixmystreet` path. Paths returned by this method are used as the `additional_template_paths` param when templating emails. A regression test is included. Additionally moves email templates for fixmystreet.com to a directory name reflecting their purpose, in the same way the web templates are arranged. --- perllib/FixMyStreet/Email.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet/Email.pm') diff --git a/perllib/FixMyStreet/Email.pm b/perllib/FixMyStreet/Email.pm index ce7dad47a..b12fcfab4 100644 --- a/perllib/FixMyStreet/Email.pm +++ b/perllib/FixMyStreet/Email.pm @@ -92,13 +92,11 @@ sub send_cron { unpack('h*', random_bytes(5, 1)), FixMyStreet->config('EMAIL_DOMAIN') ); + my @include_path = @{ $cobrand->path_to_email_templates($lang_code) }; + push @include_path, FixMyStreet->path_to( 'templates', 'email', 'default' )->stringify; my $tt = Template->new({ ENCODING => 'utf8', - INCLUDE_PATH => [ - FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker, $lang_code )->stringify, - FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker )->stringify, - FixMyStreet->path_to( 'templates', 'email', 'default' )->stringify, - ], + INCLUDE_PATH => \@include_path, }); $vars->{signature} = _render_template($tt, 'signature.txt', $vars); $vars->{site_name} = Utils::trim_text(_render_template($tt, 'site-name.txt', $vars)); -- cgit v1.2.3