diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/TfL.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/GoogleOL.pm | 2 | ||||
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 5 | ||||
-rw-r--r-- | t/Mock/Tilma.pm | 27 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 79 | ||||
-rw-r--r-- | templates/web/highwaysengland/around/_postcode_form_examples.html | 1 | ||||
-rw-r--r-- | web/cobrands/tfl/assets.js | 2 |
8 files changed, 119 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3b4fcd5..71fef3855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - Move summary failures to a separate script. - Add script to export/import body data. - Add fetch script that does combined job of fetch-comments and fetch-reports. + - Open311 improvements: + - match response templates on external status code over state - UK: - Added junction lookup, so you can search for things like "M60, Junction 2" diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm index b80929f25..8e133fa58 100644 --- a/perllib/FixMyStreet/Cobrand/TfL.pm +++ b/perllib/FixMyStreet/Cobrand/TfL.pm @@ -421,7 +421,19 @@ sub munge_reports_area_list { } sub munge_report_new_contacts { } -sub munge_report_new_bodies { } + +sub munge_report_new_bodies { + my ($self, $bodies) = @_; + + # Highways England handling + my $c = $self->{c}; + my $he = FixMyStreet::Cobrand::HighwaysEngland->new({ c => $c }); + my $on_he_road = $c->stash->{on_he_road} = $he->report_new_is_on_he_road; + + if (!$on_he_road) { + %$bodies = map { $_->id => $_ } grep { $_->name ne 'Highways England' } values %$bodies; + } +} sub munge_surrounding_london { my ($self, $bodies) = @_; diff --git a/perllib/FixMyStreet/Map/GoogleOL.pm b/perllib/FixMyStreet/Map/GoogleOL.pm index 44d0e77e7..7049b27d4 100644 --- a/perllib/FixMyStreet/Map/GoogleOL.pm +++ b/perllib/FixMyStreet/Map/GoogleOL.pm @@ -16,7 +16,7 @@ sub map_template { 'google-ol' } sub map_javascript { my $google_maps_url = "https://maps.googleapis.com/maps/api/js?v=3"; my $key = FixMyStreet->config('GOOGLE_MAPS_API_KEY'); - $google_maps_url .= "&key=$key" if $key; + $google_maps_url .= "&key=$key" if $key; [ $google_maps_url, '/vendor/OpenLayers/OpenLayers.google.js', diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 09b1f6b26..9fa81ac9e 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -304,17 +304,20 @@ sub comment_text_for_request { my $ext_code_changed = $ext_code ne $old_ext_code; my $template; if ($state_changed || $ext_code_changed) { + my $order; my $state_params = { 'me.state' => $state }; if ($ext_code) { $state_params->{'me.external_status_code'} = $ext_code; + # make sure that empty string/nulls come last. + $order = { order_by => \"me.external_status_code DESC NULLS LAST" }; }; if (my $t = $problem->response_templates->search({ auto_response => 1, -or => $state_params, - })->first) { + }, $order )->first) { $template = $t->text; } } diff --git a/t/Mock/Tilma.pm b/t/Mock/Tilma.pm index 5a11209e3..7542b1f5e 100644 --- a/t/Mock/Tilma.pm +++ b/t/Mock/Tilma.pm @@ -10,6 +10,18 @@ has json => ( }, ); +sub as_json { + my ($self, $features) = @_; + my $json = mySociety::Locale::in_gb_locale { + $self->json->encode({ + type => "FeatureCollection", + crs => { type => "name", properties => { name => "urn:ogc:def:crs:EPSG::27700" } }, + features => $features, + }); + }; + return $json; +} + sub dispatch_request { my $self = shift; @@ -25,15 +37,16 @@ sub dispatch_request { [ 539408.94, 170607.58 ], ] ] } } ]; } - my $json = mySociety::Locale::in_gb_locale { - $self->json->encode({ - type => "FeatureCollection", - crs => { type => "name", properties => { name => "urn:ogc:def:crs:EPSG::27700" } }, - features => $features, - }); - }; + my $json = $self->as_json($features); return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; }, + + sub (GET + /mapserver/highways + ?*) { + my ($self, $args) = @_; + my $json = $self->as_json([]); + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, + } __PACKAGE__->run_if_script; diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 07c3b4cdd..35be0f7b5 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -932,8 +932,6 @@ subtest 'check that external_status_code triggers auto-responses' => sub { $problem->discard_changes; is $problem->comments->count, 1, 'one comment after fetching updates'; - my $comment = $problem->comments->first; - is $problem->comments->first->text, "Thank you for your report. We will provide an update within 24 hours.", "correct external status code on first comment"; }; @@ -991,6 +989,83 @@ foreach my $test ( { $problem->comments->delete; }; } + +my $response_template_in_progress = $bodies{2482}->response_templates->create({ + title => "Acknowledgement 1", + text => "Thank you for your report. We will provide an update within 48 hours.", + auto_response => 1, + state => "in progress" +}); + +for my $test ( + { + external_code => '090', + description => 'check numeric external status code in response template override state', + }, + { + external_code => 'futher', + description => 'check alpha external status code in response template override state', + }, +) { + subtest $test->{description} => sub { + my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?> + <service_requests_updates> + <request_update> + <update_id>638344</update_id> + <service_request_id>@{[ $problem->external_id ]}</service_request_id> + <status>in_progress</status> + <description></description> + <updated_datetime>UPDATED_DATETIME</updated_datetime> + <external_status_code></external_status_code> + </request_update> + <request_update> + <update_id>638345</update_id> + <service_request_id>@{[ $problem->external_id ]}</service_request_id> + <status>in_progress</status> + <description></description> + <updated_datetime>UPDATED_DATETIME2</updated_datetime> + <external_status_code>@{[ $test->{external_code} ]}</external_status_code> + </request_update> + </service_requests_updates> + }; + + my $response_template = $bodies{2482}->response_templates->create({ + # the default ordering uses the title of the report so + # make sure this comes second + title => "Acknowledgement 2", + text => "Thank you for your report. We will provide an update within 24 hours.", + auto_response => 1, + external_status_code => $test->{external_code} + }); + + $problem->comments->delete; + + my $dt2 = $dt->clone->add( minutes => 1 ); + $requests_xml =~ s/UPDATED_DATETIME/$dt/; + $requests_xml =~ s/UPDATED_DATETIME2/$dt2/; + + my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $requests_xml } ); + + my $update = Open311::GetServiceRequestUpdates->new( + system_user => $user, + current_open311 => $o, + current_body => $bodies{2482}, + ); + + $update->process_body; + + $problem->discard_changes; + is $problem->comments->count, 2, 'two comment after fetching updates'; + + my @comments = $problem->comments; + + is $comments[0]->text, "Thank you for your report. We will provide an update within 48 hours.", "correct external status code on first comment"; + is $comments[1]->text, "Thank you for your report. We will provide an update within 24 hours.", "correct external status code on second comment"; + $problem->comments->delete; + $response_template->delete; + }; +} + subtest 'check that first comment always updates state' => sub { my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?> <service_requests_updates> diff --git a/templates/web/highwaysengland/around/_postcode_form_examples.html b/templates/web/highwaysengland/around/_postcode_form_examples.html index 7642ae5fd..5ffb7339a 100644 --- a/templates/web/highwaysengland/around/_postcode_form_examples.html +++ b/templates/web/highwaysengland/around/_postcode_form_examples.html @@ -1 +1,2 @@ <p class="form-hint" id="pc-hint">[% tprintf('eg ā%sā or ā%sā', c.cobrand.example_places) %]</p> +<p class="form-hint"><em>If you have previously made a report then please enter your reference, for example FMS1234567, into the search box to locate the latest status.</em></p> diff --git a/web/cobrands/tfl/assets.js b/web/cobrands/tfl/assets.js index 7538d45e1..203df578f 100644 --- a/web/cobrands/tfl/assets.js +++ b/web/cobrands/tfl/assets.js @@ -35,7 +35,7 @@ var tlrn_stylemap = new OpenLayers.StyleMap({ fillColor: "#ff0000", fillOpacity: 0.3, strokeColor: "#ff0000", - strokeOpacity: 0.6, + strokeOpacity: 1, strokeWidth: 2 }) }); |