aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm20
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm9
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm14
-rw-r--r--perllib/FixMyStreet/Email.pm8
6 files changed, 51 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 1a651d282..be0e91101 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -310,10 +310,7 @@ sub send_email {
from => [ $sender, _($sender_name) ],
%{ $c->stash },
%$extra_stash_values,
- additional_template_paths => [
- FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker, $c->stash->{lang_code} )->stringify,
- FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker )->stringify,
- ]
+ additional_template_paths => $c->cobrand->path_to_email_templates($c->stash->{lang_code}),
};
return if FixMyStreet::Email::is_abuser($c->model('DB')->schema, $vars->{to});
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 696234d32..af9ca50b5 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -226,7 +226,6 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
my $category_extra = '';
my $generate;
if ( $c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1 ) {
- $c->stash->{report_meta} = {};
$c->stash->{category_extras} = { $category => $c->stash->{category_extras}->{$category} };
$generate = 1;
}
@@ -641,8 +640,14 @@ sub setup_categories_and_bodies : Private {
push @category_options, $contact->category;
my $metas = $contact->get_extra_fields;
- $category_extras{ $contact->category } = $metas
- if scalar @$metas;
+ if (scalar @$metas) {
+ foreach (@$metas) {
+ if (ref $_->{values} eq 'HASH') {
+ $_->{values} = [ map { { name => $_->{name}[0], key => $_->{key}[0] } } @{$_->{values}->{value}} ];
+ }
+ }
+ $category_extras{ $contact->category } = $metas;
+ }
my $body_send_method = $bodies{$contact->body_id}->send_method || '';
$c->stash->{unresponsive}{$contact->category} = $contact->body_id
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 4dc024d48..76d73d96e 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -27,7 +27,25 @@ Returns the path to the templates for this cobrand - by default
sub path_to_web_templates {
my $self = shift;
my $paths = [
- FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
+ FixMyStreet->path_to( 'templates/web', $self->moniker ),
+ ];
+ return $paths;
+}
+
+=head1 path_to_email_templates
+
+ $path = $cobrand->path_to_email_templates( );
+
+Returns the path to the email templates for this cobrand - by default
+"templates/email/$moniker" (and then default in Email.pm).
+
+=cut
+
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ my $paths = [
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker, $lang_code ),
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker ),
];
return $paths;
}
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index c8c1eef66..61011a414 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -7,9 +7,16 @@ use constant COUNCIL_ID_BROMLEY => 2482;
sub path_to_web_templates {
my $self = shift;
return [
- FixMyStreet->path_to( 'templates/web/fixmystreet.com' )->stringify,
+ FixMyStreet->path_to( 'templates/web/fixmystreet.com' ),
];
}
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ return [
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com'),
+ ];
+}
+
# FixMyStreet should return all cobrands
sub restriction {
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 0321e0297..c8512f852 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -16,11 +16,21 @@ sub is_council {
sub path_to_web_templates {
my $self = shift;
return [
- FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
- FixMyStreet->path_to( 'templates/web/fixmystreet-uk-councils' )->stringify,
+ FixMyStreet->path_to( 'templates/web', $self->moniker ),
+ FixMyStreet->path_to( 'templates/web/fixmystreet-uk-councils' ),
];
}
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ my $paths = [
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker, $lang_code ),
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker ),
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com'),
+ ];
+ return $paths;
+}
+
sub site_key {
my $self = shift;
return $self->council_url;
diff --git a/perllib/FixMyStreet/Email.pm b/perllib/FixMyStreet/Email.pm
index ce7dad47a..d955f6f72 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' );
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));