diff options
author | Dave Arter <davea@mysociety.org> | 2018-01-18 12:02:00 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-01-23 15:46:09 +0000 |
commit | b3d26a80a0728e49d857c0fe5cbc2966512561ff (patch) | |
tree | d8a58f095fbd0268c5b8d328ed2cc16b564fee74 | |
parent | 6e415f3c6d9355312b9fb84e4ecdb68f96cff618 (diff) |
Hide 'updates not sent' message on reports sent via Open311
The 'updates are not sent to the council' message was incorrectly being
shown on reports where updates would in fact be sent. This was affecting
non-Bromley/Stevenage reports on fms.com and all cobrands using Open311.
This commit moves the logic out of the template and adds the
Problem->updates_sent_to_body method which inspects the receiving body's
Open311 configuration to determine whether updates will be sent.
The duplication of the Lewisham/Oxfordshire logic between Problem.pm and
send-comments isn't ideal but hopefully there won't be any new Open311
bodies that only send and don't receive updates. If there are we'll have
to look at refactoring that list.
-rwxr-xr-x | bin/send-comments | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 27 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 2 | ||||
-rw-r--r-- | templates/email/fixmystreet.com/update-confirm-donotsend.txt | 2 | ||||
-rw-r--r-- | templates/web/fixmystreet-uk-councils/report/updates-sidebar-notes.html | 6 | ||||
-rw-r--r-- | templates/web/fixmystreet.com/report/updates-sidebar-notes.html | 2 |
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>' ) %] |