aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm7
-rw-r--r--perllib/FixMyStreet/SendReport/NI.pm39
-rw-r--r--t/app/model/problem.t73
-rw-r--r--templates/web/default/report/new/councils_text_all.html7
5 files changed, 101 insertions, 27 deletions
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index c938565d1..763c3b160 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -42,7 +42,7 @@ sub get_council_sender {
return $send_method if $send_method;
return 'London' if $area_info->{type} eq 'LBO';
-
+ return 'NI' if $area_info->{type} eq 'LGD';
return 'Email';
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 00646748d..0e3415448 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -363,9 +363,10 @@ sub send_reports {
# on a staging server send emails to ourselves rather than the councils
my @testing_councils = split( '\|', mySociety::Config::get('TESTING_COUNCILS') );
unless ( grep { $row->council eq $_ } @testing_councils ) {
- %reporters = (
- 'FixMyStreet::SendReport::Email' => $reporters{ 'FixMyStreet::SendReport::Email' } || FixMyStreet::SendReport::Email->new()
- );
+ %reporters = map { $_ => $reporters{$_} } grep { /FixMyStreet::SendReport::(Email|NI)/ } keys %reporters;
+ unless (%reporters) {
+ %reporters = ( 'FixMyStreet::SendReport::Email' => FixMyStreet::SendReport::Email->new() );
+ }
}
}
diff --git a/perllib/FixMyStreet/SendReport/NI.pm b/perllib/FixMyStreet/SendReport/NI.pm
new file mode 100644
index 000000000..8cddeb2dc
--- /dev/null
+++ b/perllib/FixMyStreet/SendReport/NI.pm
@@ -0,0 +1,39 @@
+package FixMyStreet::SendReport::NI;
+
+use Moose;
+
+BEGIN { extends 'FixMyStreet::SendReport::Email'; }
+
+sub build_recipient_list {
+ my ( $self, $row, $h ) = @_;
+ my %recips;
+
+ my $all_confirmed = 1;
+ foreach my $council ( keys %{ $self->councils } ) {
+ my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ deleted => 0,
+ area_id => $council,
+ category => $row->category
+ } );
+
+ my ($email, $confirmed, $note) = ( $contact->email, $contact->confirmed, $contact->note );
+
+ unless ($confirmed) {
+ $all_confirmed = 0;
+ $email = 'N/A' unless $email;
+ }
+
+ my $name = $self->councils->{$council}->{name};
+ if ( $email =~ /^roads.([^@]*)\@drdni/ ) {
+ $name = "Roads Service (\u$1)";
+ $h->{councils_name} = $name;
+ }
+ push @{ $self->to }, [ $email, $name ];
+ $recips{$email} = 1;
+ }
+
+ return () unless $all_confirmed;
+ return keys %recips;
+}
+
+1;
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 818f115d1..30963229c 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -389,75 +389,100 @@ my $contact5 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
category => 'potholes',
email => 'highways@example.com',
} );
+my $contact6 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
+ %contact_params,
+ area_id => 14279, # Ballymoney
+ category => 'Street lighting',
+ email => 'roads.western@drdni.example.org',
+} );
+my $contact7 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
+ %contact_params,
+ area_id => 14279, # Ballymoney
+ category => 'Graffiti',
+ email => 'highways@example.com',
+} );
ok $contact1, "created test contact 1";
ok $contact2, "created test contact 2";
ok $contact3, "created test contact 3";
ok $contact4, "created test contact 4";
ok $contact5, "created test contact 5";
+ok $contact6, "created test contact 6";
+ok $contact7, "created test contact 7";
+my %common = (
+ email => 'system_user@example.com',
+ name => 'Andrew Smith',
+);
foreach my $test ( {
+ %common,
desc => 'sends an email',
unset_whendef => 1,
email_count => 1,
- email => 'system_user@example.com',
- name => 'Andrew Smith',
dear => qr'Dear City of Edinburgh Council',
to => qr'City of Edinburgh Council',
council => 2651,
- },
- {
+ }, {
+ %common,
desc => 'no email sent if no unsent problems',
unset_whendef => 0,
email_count => 0,
- email => 'system_user@example.com',
- name => 'Andrew Smith',
council => 2651,
- },
- {
+ }, {
+ %common,
desc => 'email to two tier council',
unset_whendef => 1,
email_count => 1,
- email => 'system_user@example.com',
- name => 'Andrew Smith',
to => qr'Gloucestershire County Council.*Cheltenham Borough Council',
dear => qr'Dear Gloucestershire County Council and Cheltenham Borough',
council => '2226,2326',
multiple => 1,
- },
- {
+ }, {
+ %common,
desc => 'email to two tier council with one missing details',
unset_whendef => 1,
email_count => 1,
- email => 'system_user@example.com',
- name => 'Andrew Smith',
to => qr'Gloucestershire County Council',
dear => qr'Dear Gloucestershire County Council,',
council => '2226|2649',
missing => qr'problem might be the responsibility of Fife.*Council'ms,
- },
- {
+ }, {
+ %common,
desc => 'email to two tier council that only shows district, district',
unset_whendef => 1,
email_count => 1,
- email => 'system_user@example.com',
- name => 'Andrew Smith',
to => qr'Lichfield District Council',
dear => qr'Dear Lichfield District Council,',
council => '2434',
cobrand => 'lichfielddc',
url => 'lichfielddc.',
- },
- {
+ }, {
+ %common,
desc => 'email to two tier council that only shows district, county',
unset_whendef => 1,
email_count => 1,
- email => 'system_user@example.com',
- name => 'Andrew Smith',
to => qr'Staffordshire County Council',
dear => qr'Dear Staffordshire County Council,',
council => '2240',
cobrand => 'lichfielddc',
url => '',
+ }, {
+ %common,
+ desc => 'directs NI correctly, 1',
+ unset_whendef => 1,
+ email_count => 1,
+ dear => qr'Dear Ballymoney Borough Council',
+ to => qr'Ballymoney Borough Council',
+ council => 14279,
+ category => 'Graffiti',
+ }, {
+ %common,
+ desc => 'directs NI correctly, 2',
+ unset_whendef => 1,
+ email_count => 1,
+ dear => qr'Dear Roads Service \(Western\)',
+ to => qr'Roads Service \(Western\)',
+ council => 14279,
+ category => 'Street lighting',
},
) {
subtest $test->{ desc } => sub {
@@ -475,7 +500,7 @@ foreach my $test ( {
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
whensent => $test->{ unset_whendef } ? undef : \'ms_current_timestamp()',
- category => 'potholes',
+ category => $test->{ category } || 'potholes',
name => $test->{ name },
cobrand => $test->{ cobrand } || 'fixmystreet',
} );
@@ -519,5 +544,7 @@ $contact2->delete;
$contact3->delete;
$contact4->delete;
$contact5->delete;
+$contact6->delete;
+$contact7->delete;
done_testing();
diff --git a/templates/web/default/report/new/councils_text_all.html b/templates/web/default/report/new/councils_text_all.html
index df3388bf3..ecc81ca18 100644
--- a/templates/web/default/report/new/councils_text_all.html
+++ b/templates/web/default/report/new/councils_text_all.html
@@ -6,6 +6,13 @@
all_council_names.join( '</strong>' _ loc(' or ') _ '<strong>' )
);
%]
+[% ELSIF all_councils.${area_ids_to_list.0}.type == 'LGD' %]
+[%
+ tprintf(
+ loc('All the information you provide here will be sent to <strong>%s</strong> or <strong>Roads Service</strong>.'),
+ all_council_names.join( '</strong>' _ loc(' or ') _ '<strong>' )
+ );
+%]
[% ELSE %]
[%
tprintf(