diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-07-09 09:32:10 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-07-09 09:32:10 +0100 |
commit | 8ab6e6105a967999dbc766d4a3fd150f5fe2c748 (patch) | |
tree | 47f07359872d5cd1024f4a6a32df9ab48a302de9 | |
parent | 0bce7c37e58e47bc3b2b864fe3fdd4072871827d (diff) | |
parent | eb85d0df6cfcdfa5eb7833c53d704967e3df761a (diff) |
Merge branch 'he-category-interactions'
-rw-r--r-- | .cypress/cypress/integration/duplicates.js | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bexley.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Buckinghamshire.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/CheshireEast.pm | 34 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/EastSussex.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Greenwich.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/IsleOfWight.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Northamptonshire.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Peterborough.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Rutland.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Westminster.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Roles/ConfirmOpen311.pm | 2 | ||||
-rw-r--r-- | t/cobrand/bucks.t | 18 |
16 files changed, 48 insertions, 81 deletions
diff --git a/.cypress/cypress/integration/duplicates.js b/.cypress/cypress/integration/duplicates.js index 406b3fb67..3dba5e38a 100644 --- a/.cypress/cypress/integration/duplicates.js +++ b/.cypress/cypress/integration/duplicates.js @@ -53,7 +53,7 @@ describe('Duplicate tests', function() { it('lets an inspector see duplicate reports coming from /reports', function() { cy.request({ method: 'POST', - url: 'http://borsetshire.localhost:3001/auth?r=/reports', + url: 'http://borsetshire.localhost:3001/auth?r=/my', form: true, body: { username: 'admin@example.org', password_sign_in: 'password' } }); diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm index ad3036711..e29856f31 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley.pm @@ -88,7 +88,7 @@ sub open311_config { $params->{multi_photos} = 1; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra, $contact) = @_; my $open311_only; diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index bd229f360..e63d722fd 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -171,7 +171,7 @@ sub open311_config { $params->{extended_description} = 0; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; my $title = $row->title; @@ -207,7 +207,11 @@ sub open311_extra_data { push @$open311_only, { name => 'fms_extra_title', value => $row->user->title }; } - return ($open311_only, [ 'feature_id', 'prow_reference' ]); + return $open311_only; +} + +sub open311_extra_data_exclude { + [ 'feature_id', 'prow_reference' ] } sub open311_config_updates { diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm index 117725273..00264afea 100644 --- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm +++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm @@ -45,16 +45,7 @@ sub send_questionnaires { return 0; } -sub open311_pre_send { - my ($self, $row, $open311) = @_; - - return unless $row->extra; - my $extra = $row->get_extra_fields; - if (@$extra) { - @$extra = grep { $_->{name} ne 'road-placement' } @$extra; - $row->set_extra_fields(@$extra); - } -} +sub open311_extra_data_exclude { [ 'road-placement' ] } sub open311_post_send { my ($self, $row, $h) = @_; @@ -103,6 +94,7 @@ sub report_new_munge_before_insert { my ($self, $report) = @_; return unless $report->category eq 'Flytipping'; + return unless $self->{c}->stash->{report}->to_body_named('Buckinghamshire'); my $placement = $self->{c}->get_param('road-placement'); return unless $placement && $placement eq 'off-road'; diff --git a/perllib/FixMyStreet/Cobrand/CheshireEast.pm b/perllib/FixMyStreet/Cobrand/CheshireEast.pm index c5e5107f3..ae537b635 100644 --- a/perllib/FixMyStreet/Cobrand/CheshireEast.pm +++ b/perllib/FixMyStreet/Cobrand/CheshireEast.pm @@ -5,6 +5,7 @@ use strict; use warnings; use Moo; +with 'FixMyStreet::Roles::ConfirmOpen311'; with 'FixMyStreet::Roles::ConfirmValidation'; sub council_area_id { 21069 } @@ -56,39 +57,6 @@ sub abuse_reports_only { 1 } sub send_questionnaires { 0 } -sub open311_config { - my ($self, $row, $h, $params) = @_; - - $params->{multi_photos} = 1; -} - -sub open311_extra_data { - my ($self, $row, $h, $extra) = @_; - - my $open311_only = [ - { name => 'report_url', - value => $h->{url} }, - { name => 'title', - value => $row->title }, - { name => 'description', - value => $row->detail }, - ]; - - # Reports made via FMS.com or the app probably won't have a site code - # value because we don't display the adopted highways layer on those - # frontends. Instead we'll look up the closest asset from the WFS - # service at the point we're sending the report over Open311. - if (!$row->get_extra_field_value('site_code')) { - if (my $site_code = $self->lookup_site_code($row)) { - push @$extra, - { name => 'site_code', - value => $site_code }; - } - } - - return $open311_only; -} - # TODO These values may not be accurate sub lookup_site_code_config { { buffer => 200, # metres diff --git a/perllib/FixMyStreet/Cobrand/EastSussex.pm b/perllib/FixMyStreet/Cobrand/EastSussex.pm index 8d95980fe..04394f776 100644 --- a/perllib/FixMyStreet/Cobrand/EastSussex.pm +++ b/perllib/FixMyStreet/Cobrand/EastSussex.pm @@ -20,7 +20,7 @@ sub open311_extra_data { } } $row->detail($row->detail . $text); - return (); + return (undef, ['sect_label', 'road_name', 'area_name']); } sub open311_post_send { diff --git a/perllib/FixMyStreet/Cobrand/Greenwich.pm b/perllib/FixMyStreet/Cobrand/Greenwich.pm index be260d0c0..de7dd5d96 100644 --- a/perllib/FixMyStreet/Cobrand/Greenwich.pm +++ b/perllib/FixMyStreet/Cobrand/Greenwich.pm @@ -44,7 +44,7 @@ sub reports_per_page { return 20; } sub admin_user_domain { 'royalgreenwich.gov.uk' } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; # Greenwich doesn't have category metadata to fill this diff --git a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm index 08741639c..84b916fc2 100644 --- a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm +++ b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm @@ -63,16 +63,7 @@ sub lookup_site_code_config { { accept_feature => sub { 1 } } } -sub open311_pre_send { - my ($self, $row, $open311) = @_; - - return unless $row->extra; - my $extra = $row->get_extra_fields; - if (@$extra) { - @$extra = grep { $_->{name} ne 'urgent' } @$extra; - $row->set_extra_fields(@$extra); - } -} +sub open311_extra_data_exclude { [ '^urgent$' ] } # Make sure fetched report description isn't shown. sub filter_report_description { "" } diff --git a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm index 3e32b0856..791e2f83f 100644 --- a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm +++ b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm @@ -91,10 +91,10 @@ sub open311_config { $params->{multi_photos} = 1; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; - return ([ + return [ { name => 'report_url', value => $h->{url} }, { name => 'title', @@ -103,10 +103,9 @@ sub open311_extra_data { value => $row->detail }, { name => 'category', value => $row->category }, - ], [ - 'emergency' - ]); + ]; } +sub open311_extra_data_exclude { [ 'emergency' ] } sub open311_get_update_munging { my ($self, $comment) = @_; diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index 8ce12a81b..aa6c9a5a5 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -122,7 +122,7 @@ sub open311_config { $params->{extended_description} = 'oxfordshire'; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; return [ diff --git a/perllib/FixMyStreet/Cobrand/Peterborough.pm b/perllib/FixMyStreet/Cobrand/Peterborough.pm index bdd19a338..dd6592a7c 100644 --- a/perllib/FixMyStreet/Cobrand/Peterborough.pm +++ b/perllib/FixMyStreet/Cobrand/Peterborough.pm @@ -41,7 +41,7 @@ sub geocoder_munge_results { sub admin_user_domain { "peterborough.gov.uk" } -around open311_extra_data => sub { +around open311_extra_data_include => sub { my ($orig, $self, $row, $h, $extra) = @_; my $open311_only = $self->$orig($row, $h, $extra); @@ -53,18 +53,8 @@ around open311_extra_data => sub { } return $open311_only; }; - # remove categories which are informational only -sub open311_pre_send { - my ($self, $row, $open311) = @_; - - return unless $row->extra; - my $extra = $row->get_extra_fields; - if (@$extra) { - @$extra = grep { $_->{name} !~ /^(PCC-|emergency$|private_land$)/i } @$extra; - $row->set_extra_fields(@$extra); - } -} +sub open311_extra_data_exclude { [ '^PCC-', '^emergency$', '^private_land$' ] } sub lookup_site_code_config { { buffer => 50, # metres diff --git a/perllib/FixMyStreet/Cobrand/Rutland.pm b/perllib/FixMyStreet/Cobrand/Rutland.pm index 63a20d893..557cf83a9 100644 --- a/perllib/FixMyStreet/Cobrand/Rutland.pm +++ b/perllib/FixMyStreet/Cobrand/Rutland.pm @@ -29,7 +29,7 @@ sub open311_config { $params->{multi_photos} = 1; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; return [ diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 7456d9ddf..4634f4b14 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -329,6 +329,13 @@ sub munge_report_new_contacts { } } +sub open311_extra_data { + my $self = shift; + my $include = $self->call_hook(open311_extra_data_include => @_); + my $exclude = $self->call_hook(open311_extra_data_exclude => @_); + push @$exclude, 'sect_label', 'road_name', 'area_name'; + return ($include, $exclude); +}; =head2 lookup_site_code diff --git a/perllib/FixMyStreet/Cobrand/Westminster.pm b/perllib/FixMyStreet/Cobrand/Westminster.pm index c9f31f7f9..40ae9f6c6 100644 --- a/perllib/FixMyStreet/Cobrand/Westminster.pm +++ b/perllib/FixMyStreet/Cobrand/Westminster.pm @@ -78,7 +78,7 @@ sub open311_config { $h->{account_id} = $id || '0'; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; # Reports made via the app probably won't have a USRN because we don't diff --git a/perllib/FixMyStreet/Roles/ConfirmOpen311.pm b/perllib/FixMyStreet/Roles/ConfirmOpen311.pm index 0845105f1..6787ba3f4 100644 --- a/perllib/FixMyStreet/Roles/ConfirmOpen311.pm +++ b/perllib/FixMyStreet/Roles/ConfirmOpen311.pm @@ -13,7 +13,7 @@ sub open311_config { $params->{multi_photos} = 1; } -sub open311_extra_data { +sub open311_extra_data_include { my ($self, $row, $h, $extra) = @_; my $open311_only = [ diff --git a/t/cobrand/bucks.t b/t/cobrand/bucks.t index 230a52f99..36e149a13 100644 --- a/t/cobrand/bucks.t +++ b/t/cobrand/bucks.t @@ -112,7 +112,6 @@ subtest 'pothole on road not sent to extra email, only confirm sent' => sub { is $report->external_id, 248, 'Report has right external ID'; }; - # report made in Flytipping category off road should get moved to other category subtest 'Flytipping not on a road gets recategorised' => sub { $mech->log_in_ok($publicuser->email); @@ -129,6 +128,23 @@ subtest 'Flytipping not on a road gets recategorised' => sub { my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; ok $report, "Found the report"; is $report->category, "Flytipping (off-road)", 'Report was recategorised correctly'; +}; + +subtest 'Flytipping not on a road going to HE does not get recategorised' => sub { + $mech->get_ok('/report/new?latitude=51.615559&longitude=-0.556903&category=Flytipping'); + $mech->submit_form_ok({ + with_fields => { + single_body_only => 'Highways England', + title => "Test Report", + detail => 'Test report details.', + category => 'Flytipping', + 'road-placement' => 'off-road', + } + }, "submit details"); + $mech->content_contains('We don’t handle this type of problem'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + ok $report, "Found the report"; + is $report->category, "Flytipping", 'Report was not recategorised'; $mech->log_out_ok; }; |