aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-10-26 11:25:01 +0100
committerStruan Donald <struan@exo.org.uk>2018-11-19 13:27:43 +0000
commit0e8c7453c40db5ade085fb759ba73fb8ecf9b18d (patch)
treedb38c5676a712bc47a12d5fa7e58f2d10042431d /perllib
parentb97ea167b85dab9ef6a3781e24a457b392f4154c (diff)
[UK] send reports on highways agency roads to highways agency
Includes an option to send to the council instead for e.g. reports on underpasses or bridges. Fixes #736
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/SendReport.pm1
-rw-r--r--perllib/FixMyStreet/SendReport/Email/Highways.pm11
-rw-r--r--perllib/FixMyStreet/SendReport/Email/SingleBodyOnly.pm28
-rw-r--r--perllib/FixMyStreet/SendReport/Email/TfL.pm22
4 files changed, 45 insertions, 17 deletions
diff --git a/perllib/FixMyStreet/SendReport.pm b/perllib/FixMyStreet/SendReport.pm
index 2739e3043..db95850e6 100644
--- a/perllib/FixMyStreet/SendReport.pm
+++ b/perllib/FixMyStreet/SendReport.pm
@@ -6,6 +6,7 @@ use MooX::Types::MooseLike::Base qw(:all);
use Module::Pluggable
sub_name => 'senders',
search_path => __PACKAGE__,
+ except => 'FixMyStreet::SendReport::Email::SingleBodyOnly',
require => 1;
has 'body_config' => ( is => 'rw', isa => HashRef, default => sub { {} } );
diff --git a/perllib/FixMyStreet/SendReport/Email/Highways.pm b/perllib/FixMyStreet/SendReport/Email/Highways.pm
new file mode 100644
index 000000000..2a1f7b305
--- /dev/null
+++ b/perllib/FixMyStreet/SendReport/Email/Highways.pm
@@ -0,0 +1,11 @@
+package FixMyStreet::SendReport::Email::Highways;
+
+use Moo;
+extends 'FixMyStreet::SendReport::Email::SingleBodyOnly';
+
+has contact => (
+ is => 'ro',
+ default => 'Pothole'
+);
+
+1;
diff --git a/perllib/FixMyStreet/SendReport/Email/SingleBodyOnly.pm b/perllib/FixMyStreet/SendReport/Email/SingleBodyOnly.pm
new file mode 100644
index 000000000..cf778c549
--- /dev/null
+++ b/perllib/FixMyStreet/SendReport/Email/SingleBodyOnly.pm
@@ -0,0 +1,28 @@
+package FixMyStreet::SendReport::Email::SingleBodyOnly;
+
+use Moo;
+extends 'FixMyStreet::SendReport::Email';
+
+has contact => (
+ is => 'ro',
+ default => sub { die 'Need to override contact' }
+);
+
+sub build_recipient_list {
+ my ( $self, $row, $h ) = @_;
+
+ return unless @{$self->bodies} == 1;
+ my $body = $self->bodies->[0];
+
+ # We don't care what the category was, look up the relevant contact
+ my $contact = $row->result_source->schema->resultset("Contact")->not_deleted->find({
+ body_id => $body->id,
+ category => $self->contact,
+ });
+ return unless $contact;
+
+ @{$self->to} = map { [ $_, $body->name ] } split /,/, $contact->email;
+ return 1;
+}
+
+1;
diff --git a/perllib/FixMyStreet/SendReport/Email/TfL.pm b/perllib/FixMyStreet/SendReport/Email/TfL.pm
index 801489c62..383df9792 100644
--- a/perllib/FixMyStreet/SendReport/Email/TfL.pm
+++ b/perllib/FixMyStreet/SendReport/Email/TfL.pm
@@ -1,23 +1,11 @@
package FixMyStreet::SendReport::Email::TfL;
use Moo;
-extends 'FixMyStreet::SendReport::Email';
+extends 'FixMyStreet::SendReport::Email::SingleBodyOnly';
-sub build_recipient_list {
- my ( $self, $row, $h ) = @_;
-
- return unless @{$self->bodies} == 1;
- my $body = $self->bodies->[0];
-
- # We don't care what the category was, look up the Traffic lights contact
- my $contact = $row->result_source->schema->resultset("Contact")->not_deleted->find({
- body_id => $body->id,
- category => 'Traffic lights',
- });
- return unless $contact;
-
- @{$self->to} = map { [ $_, $body->name ] } split /,/, $contact->email;
- return 1;
-}
+has contact => (
+ is => 'ro',
+ default => 'Traffic lights'
+);
1;