diff options
author | Struan Donald <struan@exo.org.uk> | 2012-08-22 10:57:10 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-08-22 10:57:10 +0100 |
commit | 2e0a4e8ec45579e4e5c9cf8aa123d5ab215b9703 (patch) | |
tree | c13e3c59b686e01460dc7960547f7e9c53c288bd /perllib/FixMyStreet/SendReport/Email.pm | |
parent | b99c5ff97b29a27eeba52ed24385ac30388e875c (diff) | |
parent | 88a7d38dffa3dabdf0f85573b254cea9c8ab232b (diff) |
Merge remote-tracking branch 'origin/master' into fmb-read-only
Conflicts:
.gitignore
bin/make_css
conf/general.yml-example
perllib/FixMyStreet/App/Controller/Council.pm
perllib/FixMyStreet/App/Controller/Report/New.pm
perllib/FixMyStreet/Cobrand/Default.pm
templates/web/default/around/around_index.html
templates/web/default/index.html
templates/web/emptyhomes/index.html
templates/web/fixmystreet/around/around_index.html
templates/web/fixmystreet/index.html
web/fixmystreet_app_cgi.cgi
web/fixmystreet_app_fastcgi.cgi
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Email.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email.pm | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm index 239bee715..654ed6b3a 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; @@ -26,14 +25,14 @@ sub build_recipient_list { unless ($confirmed) { $all_confirmed = 0; - #$note = 'Council ' . $row->council . ' deleted' - #unless $note; + $note = 'Council ' . $row->council . ' deleted' + unless $note; $council_email = 'N/A' unless $council_email; - #$notgot{$council_email}{$row->category}++; - #$note{$council_email}{$row->category} = $note; + $self->unconfirmed_counts->{$council_email}{$row->category}++; + $self->unconfirmed_notes->{$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,24 +40,38 @@ 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')) { + if (mySociety::Config::get('STAGING_SITE') && !FixMyStreet->test_mode) { @recips = ( mySociety::Config::get('CONTACT_EMAIL') ); } - return unless @recips; + unless ( @recips ) { + $self->error( 'No recipients' ); + return 1; + } + 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 ], |