diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm | 17 | ||||
-rw-r--r-- | perllib/Open311.pm | 13 | ||||
-rw-r--r-- | t/app/script/archive_old_enquiries.t | 35 | ||||
-rwxr-xr-x | templates/web/fixmystreet.com/about/faq-en-gb.html | 6 |
5 files changed, 66 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index bb6e0e94e..563c491db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Show Open311 service code as tooltip on admin category checkboxes. #2049 - Bulk user import admin page. #2057 - Add link to admin edit page for reports. #2071 + - Nicer Open311 errors. #2078 - Development improvements: - Add HTML email previewer. - Add CORS header to Open311 output. #2022 diff --git a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm index 31876d83d..03bc511a0 100644 --- a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm +++ b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm @@ -137,7 +137,7 @@ sub close_problems { my $problems = shift; while (my $problem = $problems->next) { my $timestamp = \'current_timestamp'; - $problem->add_to_comments( { + my $comment = $problem->add_to_comments( { text => '', created => $timestamp, confirmed => $timestamp, @@ -150,5 +150,20 @@ sub close_problems { extra => { is_superuser => 1 }, } ); $problem->update({ state => 'closed', send_questionnaire => 0 }); + + # Stop any alerts being sent out about this closure. + my @alerts = FixMyStreet::DB->resultset('Alert')->search( { + alert_type => 'new_updates', + parameter => $problem->id, + confirmed => 1, + } ); + + for my $alert (@alerts) { + my $alerts_sent = FixMyStreet::DB->resultset('AlertSent')->find_or_create( { + alert_id => $alert->id, + parameter => $comment->id, + } ); + } + } } diff --git a/perllib/Open311.pm b/perllib/Open311.pm index 577de31ea..a65e19fa6 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -257,7 +257,7 @@ sub get_service_request_updates { my $end_date = shift; my $params = { - api_key => $self->api_key, + api_key => $self->api_key || '', }; if ( $start_date || $end_date ) { @@ -420,9 +420,12 @@ sub _get { $params->{ jurisdiction_id } = $self->jurisdiction if $self->jurisdiction; $uri->path( $uri->path . $path ); + my $base_uri = $uri->clone; $uri->query_form( $params ); - $self->debug_details( $self->debug_details . "\nrequest:" . $uri->as_string ); + my $debug_request = "GET " . $base_uri->as_string . "\n\n"; + $debug_request .= join("\n", map { "$_: $params->{$_}" } keys %$params); + $self->debug_details( $self->debug_details . $debug_request ); my $content; if ( $self->test_mode ) { @@ -464,11 +467,13 @@ sub _post { $params->{jurisdiction_id} = $self->jurisdiction if $self->jurisdiction; - $params->{api_key} = $self->api_key + $params->{api_key} = ($self->api_key || '') if $self->api_key; my $req = POST $uri->as_string, $params; - $self->debug_details( $self->debug_details . "\nrequest:" . $req->as_string ); + my $debug_request = $req->method . ' ' . $uri->as_string . "\n\n"; + $debug_request .= join("\n", map { "$_: $params->{$_}" } keys %$params); + $self->debug_details( $self->debug_details . $debug_request ); my $ua = LWP::UserAgent->new(); my $res; diff --git a/t/app/script/archive_old_enquiries.t b/t/app/script/archive_old_enquiries.t index 0475cb9ea..9774d3fc3 100644 --- a/t/app/script/archive_old_enquiries.t +++ b/t/app/script/archive_old_enquiries.t @@ -75,6 +75,41 @@ subtest 'sets reports to the correct status' => sub { }; }; +subtest 'marks alerts as sent' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + }, sub { + my ($report) = $mech->create_problems_for_body(1, $oxfordshire->id, 'Test', { + areas => ',2237,', + lastupdate => '2015-12-01 07:00:00', + user_id => $user->id, + }); + my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create( + { + user => $user, + parameter => $report->id, + alert_type => 'new_updates', + whensubscribed => '2015-12-01 07:00:00', + confirmed => 1, + cobrand => 'default', + } + ); + is $alert->alerts_sent->count, 0, 'Nothing has been sent for this alert'; + + FixMyStreet::Script::ArchiveOldEnquiries::archive($opts); + + $report->discard_changes; + + is $report->state, 'closed', 'Report has been set to closed'; + + is $alert->alerts_sent->count, 1, 'Alert marked as sent for this report'; + + my $alert_sent = $alert->alerts_sent->first; + my $comment = $report->comments->first; + is $alert_sent->parameter, $comment->id, 'AlertSent created for new comment'; + }; +}; + subtest 'sends emails to a user' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'oxfordshire' ], diff --git a/templates/web/fixmystreet.com/about/faq-en-gb.html b/templates/web/fixmystreet.com/about/faq-en-gb.html index 0d6b95523..7601110a7 100755 --- a/templates/web/fixmystreet.com/about/faq-en-gb.html +++ b/templates/web/fixmystreet.com/about/faq-en-gb.html @@ -127,6 +127,9 @@ tone of their correspondence tends to be more constructive and less abusive. anonymously – just uncheck the 'show my name publicly' box on submission. This will mean that your name is not displayed on the FixMyStreet website, although it is still sent to the council. +<p>If you want to anonymise a report you made in the past, sign in to your +account (see below for how to register) and you'll see a 'Hide your name?' +option on the report. </dd> </dl> @@ -261,7 +264,8 @@ misrouted. Please include the URL (web address) of your FixMyStreet report. <p>If you've already submitted your report, but now you need to send further information to your council, you should wait until they reply to you, and then respond to their communication directly. -<p>You can also leave an update on your FixMyStreet report page, but note that + + <p>You can also leave an update on your FixMyStreet report page, but note that updates are not forwarded to the council. They are intended as a place for residents to discuss local problems and offer advice or support. <p>With this in mind, you may wish to both update your report on the site, and |