aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xbin/update-schema1
-rw-r--r--db/downgrade_0058---0057.sql5
-rw-r--r--db/schema.sql1
-rw-r--r--db/schema_0058-blank-updates-permitted.sql5
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm1
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm6
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm4
-rw-r--r--t/open311/getservicerequestupdates.t48
-rw-r--r--templates/web/base/admin/open311-form-fields.html11
10 files changed, 81 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1de079800..20a7ce037 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
- Option to send multiple photos over Open311 #1986
- Allow Open311 service definitions to include automated
attributes #1986
+ - Optionally supress blank Open311 update errors #1986
- Front end improvements:
- Improve questionnaire process. #1939 #1998
- Increase size of "sub map links" (hide pins, permalink, etc) #2003
diff --git a/bin/update-schema b/bin/update-schema
index d9322d80b..9660837c6 100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -212,6 +212,7 @@ else {
# (assuming schema change files are never half-applied, which should be the case)
sub get_db_version {
return 'EMPTY' if ! table_exists('problem');
+ return '0058' if column_exists('body', 'blank_updates_permitted');
return '0057' if column_exists('body', 'fetch_problems');
return '0056' if column_exists('users', 'email_verified');
return '0055' if column_exists('response_priorities', 'is_default');
diff --git a/db/downgrade_0058---0057.sql b/db/downgrade_0058---0057.sql
new file mode 100644
index 000000000..1ce8f527c
--- /dev/null
+++ b/db/downgrade_0058---0057.sql
@@ -0,0 +1,5 @@
+BEGIN;
+
+ALTER TABLE body DROP blank_updates_permitted;
+
+COMMIT;
diff --git a/db/schema.sql b/db/schema.sql
index 9d212e1da..739090480 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -55,6 +55,7 @@ create table body (
can_be_devolved boolean not null default 'f',
send_extended_statuses boolean not null default 'f',
fetch_problems boolean not null default 'f',
+ blank_updates_permitted boolean not null default 'f',
deleted boolean not null default 'f'
);
diff --git a/db/schema_0058-blank-updates-permitted.sql b/db/schema_0058-blank-updates-permitted.sql
new file mode 100644
index 000000000..8b6710bc0
--- /dev/null
+++ b/db/schema_0058-blank-updates-permitted.sql
@@ -0,0 +1,5 @@
+BEGIN;
+
+ALTER TABLE body ADD blank_updates_permitted boolean default 'f' not null;
+
+COMMIT;
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 27792cd9d..c12fdf9b9 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -446,6 +446,7 @@ sub body_params : Private {
%defaults = ( %defaults,
send_comments => 0,
fetch_problems => 0,
+ blank_updates_permitted => 0,
suppress_alerts => 0,
comment_user_id => undef,
send_extended_statuses => 0,
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index 95c176084..a9df1aeb7 100644
--- a/perllib/FixMyStreet/DB/Result/Body.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -46,6 +46,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"fetch_problems",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
+ "blank_updates_permitted",
+ { data_type => "boolean", default_value => \"false", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
@@ -120,8 +122,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07035 @ 2017-12-20 14:32:39
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4RaXIyQmPdyDRW+0pmk0cg
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2018-03-01 12:27:28
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dzqgZI1wkGDPS2PfJgDEIg
use Moo;
use namespace::clean;
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 8e83d08b9..f2a319f15 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -12,6 +12,7 @@ has end_date => ( is => 'ro', default => sub { undef } );
has suppress_alerts => ( is => 'rw', default => 0 );
has verbose => ( is => 'ro', default => 0 );
has schema => ( is =>'ro', lazy => 1, default => sub { FixMyStreet::DB->schema->connect } );
+has blank_updates_permitted => ( is => 'rw', default => 0 );
Readonly::Scalar my $AREA_ID_BROMLEY => 2482;
Readonly::Scalar my $AREA_ID_OXFORDSHIRE => 2237;
@@ -49,6 +50,7 @@ sub fetch {
}
$self->suppress_alerts( $body->suppress_alerts );
+ $self->blank_updates_permitted( $body->blank_updates_permitted );
$self->system_user( $body->comment_user );
$self->update_comments( $o, $body );
}
@@ -183,6 +185,8 @@ sub comment_text_for_request {
return $template->text;
}
+ return "" if $self->blank_updates_permitted;
+
print STDERR "Couldn't determine update text for $request->{update_id} (report " . $problem->id . ")\n";
return "";
}
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index da427e505..a53354685 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -1,6 +1,7 @@
#!/usr/bin/env perl
use FixMyStreet::Test;
+use Test::Output;
use CGI::Simple;
use LWP::Protocol::PSGI;
use t::Mock::Static;
@@ -782,6 +783,53 @@ foreach my $test ( {
}
}
+foreach my $test ( {
+ desc => 'normally blank text produces a warning',
+ num_alerts => 1,
+ blank_updates_permitted => 0,
+ },
+ {
+ desc => 'no warning if blank updates permitted',
+ num_alerts => 1,
+ blank_updates_permitted => 1,
+ },
+) {
+ subtest $test->{desc} => 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>closed</status>
+ <description></description>
+ <updated_datetime>UPDATED_DATETIME</updated_datetime>
+ </request_update>
+ </service_requests_updates>
+ };
+
+ $problem->state( 'confirmed' );
+ $problem->lastupdate( $dt->clone->subtract( hours => 3 ) );
+ $problem->update;
+
+ $requests_xml =~ s/UPDATED_DATETIME/$dt/;
+
+ 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,
+ blank_updates_permitted => $test->{blank_updates_permitted},
+ );
+
+ if ( $test->{blank_updates_permitted} ) {
+ stderr_is { $update->update_comments( $o, $bodies{2482} ) } '', 'No error message'
+ } else {
+ stderr_like { $update->update_comments( $o, $bodies{2482} ) } qr/Couldn't determine update text for/, 'Error message displayed'
+ }
+ $problem->discard_changes;
+ $problem->comments->delete;
+ }
+}
+
done_testing();
sub setup_xml {
diff --git a/templates/web/base/admin/open311-form-fields.html b/templates/web/base/admin/open311-form-fields.html
index 393693264..6e6eb96f0 100644
--- a/templates/web/base/admin/open311-form-fields.html
+++ b/templates/web/base/admin/open311-form-fields.html
@@ -49,6 +49,17 @@
</p>
[% IF show_body_fields %]
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "Enabling this will suppress the error message that is normally emitted when an update has no description"
+ ) %]
+ </p>
+ </div>
+ <p>
+ <input type="checkbox" id="blank_updates_permitted" name="blank_updates_permitted"[% ' checked' IF object.blank_updates_permitted %]>
+ <label for="blank_updates_permitted" class="inline">[% loc('Permit blank updates') %]</label>
+ </p>
[%# These fields aren't shown for contacts %]
<div class="admin-hint">
<p>