aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/send-comments2
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm27
-rw-r--r--t/cobrand/bromley.t2
-rw-r--r--templates/email/fixmystreet.com/update-confirm-donotsend.txt2
-rw-r--r--templates/web/fixmystreet-uk-councils/report/updates-sidebar-notes.html6
-rw-r--r--templates/web/fixmystreet.com/report/updates-sidebar-notes.html2
6 files changed, 37 insertions, 4 deletions
diff --git a/bin/send-comments b/bin/send-comments
index 7363d7a0d..aecedcb08 100755
--- a/bin/send-comments
+++ b/bin/send-comments
@@ -49,7 +49,7 @@ my $bodies = FixMyStreet::DB->resultset('Body')->search( {
while ( my $body = $bodies->next ) {
- # XXX Cobrand specific
+ # XXX Cobrand specific - see also list in Problem->updates_sent_to_body
if ($site eq 'fixmystreet.com') {
# Oxfordshire (OCC) is special:
# we do *receive* service_request_updates (aka comments) for OCC, but we never *send* them, so skip this pass
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index a32c17ffb..c73f7efca 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -867,6 +867,33 @@ sub update_send_failed {
} );
}
+=head2 updates_sent_to_body
+
+Returns 1 if updates left on this report will be sent to any of the receiving
+bodies by some mechanism. Right now that mechanism is Open311.
+
+=cut
+
+sub updates_sent_to_body {
+ my $self = shift;
+ return unless $self->send_method_used && $self->send_method_used eq 'Open311';
+
+ # Some bodies only send updates *to* FMS, they don't receive updates.
+ # NB See also the list in bin/send-comments
+ my $excluded = qr{Lewisham|Oxfordshire};
+
+ my @bodies = values %{ $self->bodies };
+ my @updates_sent = grep {
+ $_->send_comments &&
+ (
+ $_->send_method eq 'Open311' ||
+ $_->send_method eq 'Noop' # Sending might be temporarily disabled
+ ) &&
+ !($_->name =~ /$excluded/)
+ } @bodies;
+ return scalar @updates_sent;
+}
+
sub add_send_method {
my $self = shift;
my $sender = shift;
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index a3a807bb1..41e351dea 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -49,7 +49,7 @@ $mech->content_contains( 'State changed to: No further action' );
subtest 'testing special Open311 behaviour', sub {
$report->set_extra_fields();
$report->update;
- $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test' } );
+ $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test', send_comments => 1 } );
my $test_data;
FixMyStreet::override_config {
STAGING_FLAGS => { send_reports => 1 },
diff --git a/templates/email/fixmystreet.com/update-confirm-donotsend.txt b/templates/email/fixmystreet.com/update-confirm-donotsend.txt
index 8ab91836b..21f3c6ffd 100644
--- a/templates/email/fixmystreet.com/update-confirm-donotsend.txt
+++ b/templates/email/fixmystreet.com/update-confirm-donotsend.txt
@@ -1,4 +1,4 @@
-[% IF NOT update.problem.to_body_named('Bromley|Stevenage') %]
+[% IF NOT problem.updates_sent_to_body %]
Note that we do not send updates to [% update.problem.body %] - they are
intended as a place for [% site_name %] users to
discuss, support, and offer advice.
diff --git a/templates/web/fixmystreet-uk-councils/report/updates-sidebar-notes.html b/templates/web/fixmystreet-uk-councils/report/updates-sidebar-notes.html
new file mode 100644
index 000000000..e4f8dda1b
--- /dev/null
+++ b/templates/web/fixmystreet-uk-councils/report/updates-sidebar-notes.html
@@ -0,0 +1,6 @@
+<p>
+ [% IF NOT problem.updates_sent_to_body %]
+ [% loc( 'Please note that updates are not sent to the council.' ) %]
+ [% END %]
+ [% loc( 'Your information will only be used in accordance with our <a href="/privacy">privacy policy</a>' ) %]
+</p>
diff --git a/templates/web/fixmystreet.com/report/updates-sidebar-notes.html b/templates/web/fixmystreet.com/report/updates-sidebar-notes.html
index 17e3ade62..e4f8dda1b 100644
--- a/templates/web/fixmystreet.com/report/updates-sidebar-notes.html
+++ b/templates/web/fixmystreet.com/report/updates-sidebar-notes.html
@@ -1,5 +1,5 @@
<p>
- [% IF NOT problem.send_method_used.match('Open311') OR NOT problem.to_body_named('Bromley|Stevenage') %]
+ [% IF NOT problem.updates_sent_to_body %]
[% loc( 'Please note that updates are not sent to the council.' ) %]
[% END %]
[% loc( 'Your information will only be used in accordance with our <a href="/privacy">privacy policy</a>' ) %]