aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-07-20 21:08:58 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-07-20 21:15:17 +0100
commit1d22165ba38a91daa74e52ac67dd75974abdaecb (patch)
treea2559af8d39e7d25bd107763b80d9fdcd61850c2 /perllib/FixMyStreet
parent5612a350ba12f92d9f2d5dcbafc718b6d68f6e20 (diff)
Add NI sender, for handling cross-council road reports.
Diffstat (limited to 'perllib/FixMyStreet')
-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
3 files changed, 44 insertions, 4 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;