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 /perllib/FixMyStreet/DB/Result/Problem.pm | |
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.
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 27 |
1 files changed, 27 insertions, 0 deletions
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; |