diff options
-rw-r--r-- | perllib/FixMyStreet/App/Model/PhotoSet.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bexley.pm | 35 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Hounslow.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/PhotoStorage.pm | 1 | ||||
-rw-r--r-- | t/cobrand/bexley.t | 18 | ||||
-rw-r--r-- | t/cobrand/hounslow.t | 18 | ||||
-rw-r--r-- | templates/web/bexley/around/intro.html | 2 |
7 files changed, 67 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index 1d9ccd7cd..c9f1c48a1 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -8,7 +8,6 @@ use Scalar::Util 'openhandle', 'blessed'; use Image::Size; use IPC::Cmd qw(can_run); use IPC::Open3; -use MIME::Base64; use FixMyStreet; use FixMyStreet::ImageMagick; diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm index 727382ec0..8720f42d8 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley.pm @@ -85,17 +85,34 @@ sub open311_post_send { # Check Open311 was successful return unless $row->external_id; - return unless $row->category eq 'Abandoned and untaxed vehicles' - || $row->category eq 'Animal fouling'; - - my $mb = FixMyStreet->config('STAGING_SITE') ? 'digital-team' : 'P1sfromContactCentre'; - my $e = join('@', $mb, $self->admin_user_domain); - my $sender = FixMyStreet::SendReport::Email->new( to => [ [ $e, 'Bexley P1 email' ] ] ); - if ($row->category eq 'Abandoned and untaxed vehicles') { - my ($burnt) = grep { $_->{name} eq 'burnt' } @{$row->get_extra_fields}; - return unless $burnt && $burnt->{value} eq 'Yes'; + my $burnt = $row->get_extra_field_value('burnt') || ''; + return unless $burnt eq 'Yes'; + } + + my @lighting = ( + 'Lamp post', + 'Light in multi-storey car park', + 'Light in outside car park', + 'Light in park or open space', + 'Traffic bollard', + 'Traffic sign light', + 'Underpass light', + 'Zebra crossing light', + ); + my %lighting = map { $_ => 1 } @lighting; + + my $emails = $self->feature('open311_email') || return; + my ($e, $n); + if ($row->category eq 'Abandoned and untaxed vehicles' || $row->category eq 'Dead animal') { + $e = $emails->{p1}; + $n = 'Bexley P1 email'; + } elsif ($lighting{$row->category}) { + $e = $emails->{lighting}; + $n = 'FixMyStreet Bexley Street Lighting'; } + return unless $e; + my $sender = FixMyStreet::SendReport::Email->new( to => [ [ $e, $n ] ] ); $self->open311_config($row); # Populate NSGRef again if needed diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm index 1628715c6..ad764fdfd 100644 --- a/perllib/FixMyStreet/Cobrand/Hounslow.pm +++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm @@ -181,8 +181,9 @@ sub lookup_site_code_config { { # their cobrand at all. sub problems_restriction { my ($self, $rs) = @_; + my $table = ref $rs eq 'FixMyStreet::DB::ResultSet::Nearby' ? 'problem' : 'me'; return $rs->to_body($self->body)->search({ - 'me.confirmed' => { '>=', '2019-05-06' } + "$table.confirmed" => { '>=', '2019-05-06' } }); } diff --git a/perllib/FixMyStreet/PhotoStorage.pm b/perllib/FixMyStreet/PhotoStorage.pm index 558c93749..9b0e5c9c3 100644 --- a/perllib/FixMyStreet/PhotoStorage.pm +++ b/perllib/FixMyStreet/PhotoStorage.pm @@ -1,5 +1,6 @@ package FixMyStreet::PhotoStorage; +use MIME::Base64; use Moose; use Digest::SHA qw(sha1_hex); use Module::Load; diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t index 2f74ac03a..f6ec1014d 100644 --- a/t/cobrand/bexley.t +++ b/t/cobrand/bexley.t @@ -30,11 +30,13 @@ my $mech = FixMyStreet::TestMech->new; my $body = $mech->create_body_ok(2494, 'London Borough of Bexley', { send_method => 'Open311', api_key => 'key', 'endpoint' => 'e', 'jurisdiction' => 'j' }); $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"); 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' } } }, }, sub { subtest 'cobrand displays council name' => sub { @@ -65,6 +67,22 @@ FixMyStreet::override_config { my $email = $mech->get_email; like $email->header('To'), qr/"Bexley P1 email".*bexley/; like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/; + $mech->clear_emails_ok; + }; + + ($report) = $mech->create_problems_for_body(1, $body->id, 'Lamp', { + category => 'Lamp post', cobrand => 'bexley', + latitude => 51.408484, longitude => 0.074653, + }); + + subtest 'Correct email sent' => sub { + my $test_data = FixMyStreet::Script::Reports::send(); + my $req = $test_data->{test_req_used}; + my $c = CGI::Simple->new($req->content); + is $c->param('service_code'), 'LAMP'; + + my $email = $mech->get_email; + like $email->header('To'), qr/thirdparty/; }; }; diff --git a/t/cobrand/hounslow.t b/t/cobrand/hounslow.t index 8fac848b1..43a5a5523 100644 --- a/t/cobrand/hounslow.t +++ b/t/cobrand/hounslow.t @@ -21,11 +21,18 @@ $mech->create_contact_ok( $mech->create_problems_for_body(1, $hounslow_id, 'An old problem made before Hounslow FMS launched', { confirmed => '2018-12-25 09:00', lastupdate => '2018-12-25 09:00', + latitude => 51.482286, + longitude => -0.328163, + }); $mech->create_problems_for_body(1, $hounslow_id, 'A brand new problem made on the Hounslow site', { + latitude => 51.482286, + longitude => -0.328163, cobrand => 'hounslow' }); my ($report) = $mech->create_problems_for_body(1, $hounslow_id, 'A brand new problem made on fixmystreet.com', { + latitude => 51.482286, + longitude => -0.328163, external_id => 'ABC123', cobrand => 'fixmystreet' }); @@ -49,7 +56,18 @@ subtest "it does not show old reports on Hounslow" => sub { ALLOWED_COBRANDS => 'hounslow', }, sub { $mech->get_ok('/reports/Hounslow'); + $mech->content_lacks('An old problem made before Hounslow FMS launched'); + $mech->content_contains('A brand new problem made on the Hounslow site') or diag $mech->content; + $mech->content_contains('A brand new problem made on fixmystreet.com'); + }; +}; +subtest "it shows the right things on an /around page" => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => 'hounslow', + }, sub { + $mech->get_ok('/around?pc=TW7+5JN'); $mech->content_lacks('An old problem made before Hounslow FMS launched'); $mech->content_contains('A brand new problem made on the Hounslow site') or diag $mech->content; $mech->content_contains('A brand new problem made on fixmystreet.com'); diff --git a/templates/web/bexley/around/intro.html b/templates/web/bexley/around/intro.html new file mode 100644 index 000000000..8110e5347 --- /dev/null +++ b/templates/web/bexley/around/intro.html @@ -0,0 +1,2 @@ + <h1>[% loc('Report, view, or discuss local problems') %]</h1> + <h2>[% loc('(like graffiti, potholes, broken paving slabs, or street lighting)') %]</h2> |