diff options
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | docs/_includes/admin-tasks-content.md | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 48 | ||||
-rw-r--r-- | t/app/controller/report_new_update.t | 71 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 37 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 2 | ||||
-rw-r--r-- | templates/web/peterborough/front/pre-steps.html | 8 | ||||
-rw-r--r-- | web/cobrands/peterborough/base.scss | 13 | ||||
-rw-r--r-- | web/cobrands/sass/_layout.scss | 1 |
9 files changed, 157 insertions, 33 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 93c4747b8..ad53ca547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,14 @@ - Disable staff private tickbox on new reports if category is private. #2961 - Move stats from main admin index to stats index. - Speed up dashboard export and report search. + - Allow a template to be an initial update on reports. #2973 - Bugfixes - Application user in Docker container can't install packages. #2914 - Look at all categories when sending reports. - Provide access to staff-only categories in admin. - Maintain group on pin move with same category in multiple groups. #2962 - - Fix sorting by most commented on /around map view. + - Remove unnecessary margin-right on #postcodeForm. #3010 + - Fix sorting by most commented on /around map view. #3013 - Development improvements: - Refactor Script::Report into an object. - Move summary failures to a separate script. diff --git a/docs/_includes/admin-tasks-content.md b/docs/_includes/admin-tasks-content.md index 860d1f21c..7e3d47efe 100644 --- a/docs/_includes/admin-tasks-content.md +++ b/docs/_includes/admin-tasks-content.md @@ -748,6 +748,12 @@ process. In this instance, if your Open311 server returns extra text as part of the update, you may put the placeholder `{% raw %}{{description}}{% endraw %}` in the template here, and that placeholder will be replaced by the text from the Open311 server. +If you don’t have an Open311 connection, or your Open311 connection does not +provide an immediate initial update, there is a special case where if a +template is assigned to the Open state, and marked as ‘auto-response’, then it +will automatically be added as a first update to any new report created that +matches the template (ie. in the relevant category if assigned). This lets +you give e.g. estimated timescales or other useful information up front. #### Editing or deleting a template diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 69d20171a..fc1a78cd5 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -158,7 +158,7 @@ sub report_new_ajax : Path('mobile') : Args(0) { my $report = $c->stash->{report}; if ( $report->confirmed ) { - $c->forward( 'create_reporter_alert' ); + $c->forward( 'create_related_things' ); $c->stash->{ json_response } = { success => 1, report => $report->id }; } else { $c->forward( 'send_problem_confirm_email' ); @@ -1363,7 +1363,7 @@ sub process_confirmation : Private { ); # Subscribe problem reporter to email updates - $c->forward( '/report/new/create_reporter_alert' ); + $c->forward( '/report/new/create_related_things' ); # log the problem creation user in to the site if ( $data->{name} || $data->{password} ) { @@ -1623,7 +1623,7 @@ sub redirect_or_confirm_creation : Private { # If confirmed send the user straight there. if ( $report->confirmed ) { # Subscribe problem reporter to email updates - $c->forward( 'create_reporter_alert' ); + $c->forward( 'create_related_things' ); if ($c->stash->{contributing_as_another_user} && $report->user->email && $report->user->id != $c->user->id && !$c->cobrand->report_sent_confirmation_email) { @@ -1665,13 +1665,51 @@ sub redirect_or_confirm_creation : Private { $c->log->info($report->user->id . ' created ' . $report->id . ", $thing sent, " . ($c->stash->{token_data}->{password} ? 'password set' : 'password not set')); } -sub create_reporter_alert : Private { +sub create_related_things : Private { my ( $self, $c ) = @_; + my $problem = $c->stash->{report}; + + # If there is a special template, create a comment using that + foreach my $body (values %{$problem->bodies}) { + my $user = $body->comment_user or next; + + my %open311_conf = ( + endpoint => $body->endpoint || '', + api_key => $body->api_key || '', + jurisdiction => $body->jurisdiction || '', + extended_statuses => $body->send_extended_statuses, + ); + + my $cobrand = $body->get_cobrand_handler; + $cobrand->call_hook(open311_config_updates => \%open311_conf) + if $cobrand; + + my $open311 = Open311->new(%open311_conf); + my $updates = Open311::GetServiceRequestUpdates->new( + system_user => $user, + current_open311 => $open311, + current_body => $body, + blank_updates_permitted => 1, + ); + + my $description = $updates->comment_text_for_request({}, $problem, 'confirmed', 'dummy', '', ''); + next unless $description; + + my $request = { + service_request_id => $problem->id, + update_id => 'auto-internal', + comment_time => DateTime->now, + status => 'open', + description => $description, + }; + $updates->process_update($request, $problem); + } + + # And now the reporter alert return if $c->stash->{no_reporter_alert}; return if $c->cobrand->call_hook('suppress_reporter_alerts'); - my $problem = $c->stash->{report}; my $alert = $c->model('DB::Alert')->find_or_create( { user => $problem->user, alert_type => 'new_updates', diff --git a/t/app/controller/report_new_update.t b/t/app/controller/report_new_update.t new file mode 100644 index 000000000..cbb31cea4 --- /dev/null +++ b/t/app/controller/report_new_update.t @@ -0,0 +1,71 @@ +use FixMyStreet::TestMech; + +# disable info logs for this test run +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + +my $mech = FixMyStreet::TestMech->new; + +my $comment_user = $mech->create_user_ok('systemuser@example.org', name => 'Glos Council'); +my $body = $mech->create_body_ok(2226, 'Gloucestershire County Council', { + comment_user => $comment_user, +}); + +$mech->create_contact_ok( + body_id => $body->id, + category => 'Potholes', + email => 'potholes@example.com', +); + +my $user = $mech->log_in_ok('test-2@example.com'); + +subtest "test report creation with no initial auto-update" => sub { + my $report = make_report(); + my $comment = FixMyStreet::DB->resultset('Comment')->count; + is $comment, 0, 'No comments left'; + $report->delete; +}; + +my $template = FixMyStreet::DB->resultset("ResponseTemplate")->create({ + body => $body, + state => 'confirmed', + title => 'Initial email response', + text => 'Thanks for your report. We will investigate within 5 working days.', + auto_response => 1, +}); +ok $template, 'Template created'; + +subtest "test report creation with initial auto-update" => sub { + my $report = make_report(); + my $comment = FixMyStreet::DB->resultset('Comment')->single; + is $comment->text, 'Thanks for your report. We will investigate within 5 working days.'; + is $comment->problem->id, $report->id; + is $comment->user->id, $comment_user->id; + is $comment->external_id, 'auto-internal'; + is $comment->name, 'Glos Council'; +}; + +done_testing; + +sub make_report { + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/around?pc=GL50+2PR'); + $mech->follow_link_ok({ text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); + $mech->submit_form_ok({ + with_fields => { + title => "Test Report", + detail => 'Test report details.', + name => 'Joe Bloggs', + category => 'Potholes', + } + }, "submit good details"); + }; + + my $report = $user->problems->first; + ok $report, "Found the report"; + + return $report; +} diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index 1d59909b9..65c6a3864 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -31,7 +31,7 @@ subtest 'check /around?ajax defaults to open reports only' => sub { } FixMyStreet::override_config { - ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ], + ALLOWED_COBRANDS => 'oxfordshire', }, sub { my $json = $mech->get_ok_json( '/around?ajax=1&status=all&bbox=' . $bbox ); my $pins = $json->{pins}; @@ -47,13 +47,14 @@ subtest 'check /around?ajax defaults to open reports only' => sub { } }; -my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3 })->all; +my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3, order_by => 'id' })->all; -subtest 'can use customer reference to search for reports' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { +FixMyStreet::override_config { + ALLOWED_COBRANDS => 'oxfordshire', + MAPIT_URL => 'http://mapit.uk/', +}, sub { + + subtest 'can use customer reference to search for reports' => sub { my $problem = $problems[0]; $problem->set_extra_metadata( customer_reference => 'ENQ12456' ); $problem->update; @@ -61,16 +62,11 @@ subtest 'can use customer reference to search for reports' => sub { $mech->get_ok('/around?pc=ENQ12456'); is $mech->uri->path, '/report/' . $problem->id, 'redirects to report'; }; -}; -my $user = $mech->create_user_ok( 'user@example.com', name => 'Test User' ); -my $user2 = $mech->create_user_ok( 'user2@example.com', name => 'Test User2' ); + subtest 'check unable to fix label' => sub { + my $user = $mech->create_user_ok( 'user@example.com', name => 'Test User' ); + my $user2 = $mech->create_user_ok( 'user2@example.com', name => 'Test User2' ); -subtest 'check unable to fix label' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { my $problem = $problems[0]; $problem->state( 'unable to fix' ); $problem->update; @@ -104,13 +100,8 @@ subtest 'check unable to fix label' => sub { my $body = $mech->get_text_body_from_email($email); like $body, qr/Investigation complete/, 'state correct in email'; }; -}; -subtest 'extra CSV columns are present' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { + subtest 'extra CSV columns are present' => sub { $problems[1]->update({ external_id => $problems[1]->id }); $problems[2]->update({ external_id => "123098123" }); @@ -139,6 +130,4 @@ subtest 'extra CSV columns are present' => sub { }; }; -END { - done_testing(); -} +done_testing(); diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 35be0f7b5..4651c38b2 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -1057,7 +1057,7 @@ for my $test ( $problem->discard_changes; is $problem->comments->count, 2, 'two comment after fetching updates'; - my @comments = $problem->comments; + my @comments = $problem->comments->search(undef, { order_by => 'confirmed' }); 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"; diff --git a/templates/web/peterborough/front/pre-steps.html b/templates/web/peterborough/front/pre-steps.html new file mode 100644 index 000000000..5973c83d2 --- /dev/null +++ b/templates/web/peterborough/front/pre-steps.html @@ -0,0 +1,8 @@ +<p class="covid-banner"> + <strong>Please note:</strong> + during the Coronavirus (COVID-19) pandemic it will not be possible for us to + action or respond to all reports within regular time-frames. While we are + working hard to ensure key services are maintained and focusing on high + priority issues, you can + <a href="https://www.peterborough.gov.uk/healthcare/public-health/coronavirus/coronavirus-covid-19-overview">find advice and information on our services online</a>. +</p> diff --git a/web/cobrands/peterborough/base.scss b/web/cobrands/peterborough/base.scss index 58b31c66b..67e199cca 100644 --- a/web/cobrands/peterborough/base.scss +++ b/web/cobrands/peterborough/base.scss @@ -134,4 +134,15 @@ a, margin: 0 0.5em; font-size: 1.1em; } -}
\ No newline at end of file +} + +.covid-banner { + background-color: #AF5412; + color: white; + padding: 2em; + font-size: 1.2em; + a { + text-decoration: underline; + color: white; + } +} diff --git a/web/cobrands/sass/_layout.scss b/web/cobrands/sass/_layout.scss index fcbb193bc..02ded6fc1 100644 --- a/web/cobrands/sass/_layout.scss +++ b/web/cobrands/sass/_layout.scss @@ -842,7 +842,6 @@ textarea.form-error { background:none; overflow:hidden; padding-bottom: 0; - margin-#{$right}: 0.5em; label { margin:0.5em 0; } |