aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-11-28 17:17:58 +0000
committerStruan Donald <struan@exo.org.uk>2011-11-28 17:17:58 +0000
commitbecb211aac950c1557d634bd0b5aba402081d483 (patch)
treeb75a87960ebb77dd9288c23c42a9e6390abebef2
parentda90a635167cec6fad523a651620770ceb432f38 (diff)
add in postcode to email alert titles
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm8
-rw-r--r--t/app/controller/alert_new.t3
2 files changed, 7 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index e387f3105..83553cdfd 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -91,7 +91,8 @@ sub email_alerts ($) {
# $data{data} .= _get_address_from_gecode( $row->{geocode} ) if exists $row->{geocode} and $ref =~ /ward|council/;
$data{data} .= $row->{item_text} . "\n\n------\n\n";
} else {
- $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}\n\n";
+ my $postcode = $row->{postcode} ? ", $row->{postcode}" : '';
+ $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}$postcode\n\n";
# comment out untill we've populated the geocode field
# $data{data} .= _get_address_from_gecode( $row->{geocode} ) if exists $row->{geocode} and $ref =~ /ward|council/;
# $data{data} .= "\n\n------\n\n";
@@ -141,7 +142,7 @@ sub email_alerts ($) {
};
my $states = "'" . join( "', '", FixMyStreet::DB::Result::Problem::visible_states() ) . "'";
my %data = ( template => $template, data => '', alert_id => $alert->id, alert_email => $alert->user->email, lang => $alert->lang, cobrand => $alert->cobrand, cobrand_data => $alert->cobrand_data );
- my $q = "select problem.id, problem.geocode, problem.title from problem_find_nearby(?, ?, ?) as nearby, problem, users
+ my $q = "select problem.id, problem.postcode, problem.geocode, problem.title from problem_find_nearby(?, ?, ?) as nearby, problem, users
where nearby.problem_id = problem.id
and problem.user_id = users.id
and problem.state in ($states)
@@ -157,7 +158,8 @@ sub email_alerts ($) {
alert_id => $alert->id,
parameter => $row->{id},
} );
- $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}\n\n";
+ my $postcode = $row->{postcode} ? ", $row->{postcode}" : '';
+ $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}$postcode\n\n";
# comment out untill we've populated the geocode field
# $data{data} .= _get_address_from_gecode( $row->{geocode} ) . "\n\n" if exists $row->{geocode};
# $data{data} .= "\n\n------\n\n";
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 580a5ad9a..8231b1996 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -452,8 +452,9 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
$count++ if $_->body =~ /The following updates have been left on this problem:/;
$count++ if $_->body =~ /The following new problems have been reported to City of\s*Edinburgh Council:/;
$count++ if $_->body =~ /The following nearby problems have been added:/;
+ $count++ if $_->body =~ / - Testing, EH1 1BB/;
}
- is $count, 3, 'Three emails with the right things in them';
+ is $count, 5, 'Three emails with the right things in them';
my $email = $emails[0];
like $email->body, qr/Other User/, 'Update name given';