aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/Bexley.pm22
-rw-r--r--t/cobrand/bexley.t14
2 files changed, 26 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm
index 1b960f206..95c9aac84 100644
--- a/perllib/FixMyStreet/Cobrand/Bexley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bexley.pm
@@ -111,11 +111,6 @@ sub open311_post_send {
# Check Open311 was successful
return unless $row->external_id;
- if ($row->category eq 'Abandoned and untaxed vehicles') {
- my $burnt = $row->get_extra_field_value('burnt') || '';
- return unless $burnt eq 'Yes';
- }
-
my @lighting = (
'Lamp post',
'Light in multi-storey car park',
@@ -136,10 +131,15 @@ sub open311_post_send {
my $emails = $self->feature('open311_email') || return;
my $dangerous = $row->get_extra_field_value('dangerous') || '';
- my $reportType = $row->get_extra_field_value('reportType') || '';
my $p1_email = 0;
- if ($row->category eq 'Parks and open spaces') {
+ if ($row->category eq 'Abandoned and untaxed vehicles') {
+ my $burnt = $row->get_extra_field_value('burnt') || '';
+ $p1_email = 1 if $burnt eq 'Yes';
+ } elsif ($row->category eq 'Dead animal') {
+ $p1_email = 1;
+ } elsif ($row->category eq 'Parks and open spaces') {
+ my $reportType = $row->get_extra_field_value('reportType') || '';
$p1_email = 1 if $reportType =~ /locked in a park|Wild animal/;
$p1_email = 1 if $dangerous eq 'Yes' && $reportType =~ /Playgrounds|park furniture|gates are broken|Vandalism|Other/;
} elsif (!$lighting{$row->category}) {
@@ -147,7 +147,7 @@ sub open311_post_send {
}
my @to;
- if ($row->category eq 'Abandoned and untaxed vehicles' || $row->category eq 'Dead animal' || $p1_email) {
+ if ($p1_email) {
push @to, [ $emails->{p1}, 'Bexley P1 email' ] if $emails->{p1};
}
if ($lighting{$row->category} && $emails->{lighting}) {
@@ -158,6 +158,12 @@ sub open311_post_send {
my @flooding = split /,/, $emails->{flooding};
push @to, [ $_, 'FixMyStreet Bexley Flooding' ] for @flooding;
}
+ if ($contact->email =~ /^Uniform/ && $emails->{eh}) {
+ my @eh = split ',', $emails->{eh};
+ push @to, [ $_, 'FixMyStreet Bexley EH' ] for @eh;
+ $row->push_extra_fields({ name => 'uniform_id', description => 'Uniform ID', value => $row->external_id });
+ }
+
return unless @to;
my $sender = FixMyStreet::SendReport::Email->new( to => \@to );
diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t
index 5ac0562ea..18026dbaf 100644
--- a/t/cobrand/bexley.t
+++ b/t/cobrand/bexley.t
@@ -34,6 +34,7 @@ my $body = $mech->create_body_ok(2494, 'London Borough of Bexley', {
$mech->create_contact_ok(body_id => $body->id, category => 'Abandoned and untaxed vehicles', email => "ABAN");
$mech->create_contact_ok(body_id => $body->id, category => 'Lamp post', email => "LAMP");
$mech->create_contact_ok(body_id => $body->id, category => 'Parks and open spaces', email => "ConfirmPARK");
+$mech->create_contact_ok(body_id => $body->id, category => 'Flooding in the road', email => "FLOD");
$mech->create_contact_ok(body_id => $body->id, category => 'Flytipping', email => "UniformFLY");
$mech->create_contact_ok(body_id => $body->id, category => 'Dead animal', email => "ANIM");
my $category = $mech->create_contact_ok(body_id => $body->id, category => 'Something dangerous', email => "DANG");
@@ -44,7 +45,12 @@ FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'bexley' ],
MAPIT_URL => 'http://mapit.uk/',
STAGING_FLAGS => { send_reports => 1, skip_checks => 0 },
- COBRAND_FEATURES => { open311_email => { bexley => { p1 => 'p1@bexley', lighting => 'thirdparty@notbexley.example.com,another@notbexley.example.com' } } },
+ COBRAND_FEATURES => { open311_email => { bexley => {
+ p1 => 'p1@bexley',
+ lighting => 'thirdparty@notbexley.example.com,another@notbexley.example.com',
+ flooding => 'flooding@bexley',
+ eh => 'eh@bexley',
+ } } },
}, sub {
subtest 'cobrand displays council name' => sub {
@@ -84,7 +90,8 @@ FixMyStreet::override_config {
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } },
{ category => 'Lamp post', code => 'LAMP', email => 'thirdparty.*another',
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
- { category => 'Flytipping', code => 'UniformFLY' },
+ { category => 'Flytipping', code => 'UniformFLY', email => 'EH.*eh@bexley' },
+ { category => 'Flooding in the road', code => 'FLOD', email => 'Flooding.*flooding' },
) {
($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', {
category => $test->{category}, cobrand => 'bexley',
@@ -117,6 +124,9 @@ FixMyStreet::override_config {
}
if ($test->{code} =~ /Confirm/) {
like $mech->get_text_body_from_email($email), qr/Site code: Road ID/;
+ } elsif ($test->{code} =~ /Uniform/) {
+ like $mech->get_text_body_from_email($email), qr/UPRN: Road ID/;
+ like $mech->get_text_body_from_email($email), qr/Uniform ID: 248/;
} else {
like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/;
}