aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport/Email.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-07-20 18:49:14 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-07-20 18:49:14 +0100
commit5612a350ba12f92d9f2d5dcbafc718b6d68f6e20 (patch)
tree099f804cd66f57dcda49f2d4f35c0bbfbc113e67 /perllib/FixMyStreet/SendReport/Email.pm
parent3f5bf7ae6f87e9da2faa761065d7c6cc590183ff (diff)
Simplify SendReport code, moving some Email only bits to that module.
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Email.pm')
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm26
1 files changed, 18 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index 239bee715..dec204b1c 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -7,8 +7,7 @@ BEGIN { extends 'FixMyStreet::SendReport'; }
use mySociety::EmailUtil;
sub build_recipient_list {
- my $self = shift;
- my $row = shift;
+ my ( $self, $row, $h ) = @_;
my %recips;
my $all_confirmed = 1;
@@ -33,7 +32,7 @@ sub build_recipient_list {
#$note{$council_email}{$row->category} = $note;
}
- push @{ $self->to }, [ $council_email, $self->councils->{ $council } ];
+ push @{ $self->to }, [ $council_email, $self->councils->{ $council }->{name} ];
$recips{$council_email} = 1;
}
@@ -41,13 +40,23 @@ sub build_recipient_list {
return keys %recips;
}
+sub get_template {
+ my ( $self, $row ) = @_;
+
+ my $template = 'submit.txt';
+ $template = 'submit-brent.txt' if $row->council eq 2488 || $row->council eq 2237;
+ my $template_path = FixMyStreet->path_to( "templates", "email", $row->cobrand, $template )->stringify;
+ $template_path = FixMyStreet->path_to( "templates", "email", "default", $template )->stringify
+ unless -e $template_path;
+ $template = Utils::read_file( $template_path );
+ return $template;
+}
+
sub send {
my $self = shift;
- my ( $row, $h, $to, $template, $recips, $nomail, $areas_info ) = @_;
-
- my @recips;
+ my ( $row, $h ) = @_;
- @recips = $self->build_recipient_list( $row, $areas_info );
+ my @recips = $self->build_recipient_list( $row, $h );
# on a staging server send emails to ourselves rather than the councils
if (mySociety::Config::get('STAGING_SITE')) {
@@ -56,9 +65,10 @@ sub send {
return unless @recips;
+ my ($verbose, $nomail) = CronFns::options();
my $result = FixMyStreet::App->send_email_cron(
{
- _template_ => $template,
+ _template_ => $self->get_template( $row ),
_parameters_ => $h,
To => $self->to,
From => [ $row->user->email, $row->name ],