Skip to content

Commit

Permalink
[Bexley] Change when flytipping P1 email sent.
Browse files Browse the repository at this point in the history
Out of hours, only send if answer to both questions is Yes.
  • Loading branch information
dracos committed Sep 21, 2023
1 parent cf892a6 commit 8522ff9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions perllib/FixMyStreet/Cobrand/Bexley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ sub open311_post_send {
my $emails = $self->feature('open311_email') || return;
my $dangerous = $row->get_extra_field_value('dangerous') || '';

my $is_out_of_hours = _is_out_of_hours();

my $p1_email = 0;
my $outofhours_email = 0;
if ($row->category eq 'Abandoned and untaxed vehicles') {
Expand Down Expand Up @@ -251,7 +253,9 @@ sub open311_post_send {
if ($blocking eq 'Yes' || $hazardous eq 'Yes') {
$outofhours_email = 1;
}
$p1_email = 1;
if (!$is_out_of_hours || ($blocking eq 'Yes' && $hazardous eq 'Yes')) {
$p1_email = 1;
}
} elsif ($row->category eq 'Alleyway') { #FlytippingAlleyway
$p1_email = 1 if $dangerous eq 'Yes';
} elsif ($row->category eq 'Obstructions on pavements and roads') {
Expand All @@ -278,7 +282,7 @@ sub open311_post_send {
push @to, email_list($p1_email_to_use, 'Bexley P1 email') if $p1_email;
push @to, email_list($emails->{lighting}, 'FixMyStreet Bexley Street Lighting') if $lighting{$row->category};
push @to, email_list($emails->{flooding}, 'FixMyStreet Bexley Flooding') if $flooding{$row->category};
push @to, email_list($emails->{outofhours}, 'Bexley out of hours') if $outofhours_email && _is_out_of_hours();
push @to, email_list($emails->{outofhours}, 'Bexley out of hours') if $outofhours_email && $is_out_of_hours;
if ($contact->email =~ /^Uniform/) {
push @to, email_list($emails->{eh}, 'FixMyStreet Bexley EH');
$row->push_extra_fields({ name => 'uniform_id', description => 'Uniform ID', value => $row->external_id });
Expand Down
10 changes: 8 additions & 2 deletions t/cobrand/bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ FixMyStreet::override_config {
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
{ category => 'Flytipping', code => 'UniformFLY', email => ['eh'] },
{ category => 'Graffiti', code => 'GRAF', email => ['p1'], extra => { 'name' => 'offensive', description => 'Is the graffiti racist or offensive?', 'value' => 'Yes' } },
{ category => 'Carriageway', code => 'CARRIAGEWAY', email => ['p1'] },
{ category => 'Carriageway', code => 'CARRIAGEWAY', email => ['p1', 'outofhours', 'ooh2'],
{ category => 'Carriageway', code => 'CARRIAGEWAY', },
{ category => 'Carriageway', code => 'CARRIAGEWAY', email => ['outofhours', 'ooh2'],
extra => { 'name' => 'blocking', description => 'Flytipping blocking carriageway?', 'value' => 'Yes' } },
{ category => 'Carriageway', code => 'CARRIAGEWAY', email => ['p1', 'outofhours', 'ooh2'],
extra => [
{ 'name' => 'blocking', description => 'Flytipping blocking carriageway?', 'value' => 'Yes' },
{ 'name' => 'hazardous', value => 'Yes' },
],
},
{ category => 'Obstructions on pavements and roads', code => 'OBSTR', email => ['p1'],
extra => { 'name' => 'reportType', description => 'Type of obstruction?', 'value' => 'Tables and Chairs' } },
{ category => 'Obstructions on pavements and roads', code => 'OBSTR', email => ['p1', 'outofhours', 'ooh2'],
Expand Down

0 comments on commit 8522ff9

Please sign in to comment.