diff options
author | Struan Donald <struan@exo.org.uk> | 2018-03-26 17:09:26 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-04-03 11:08:21 +0100 |
commit | a253bba519da66f2b0d3de09de895b5364de277f (patch) | |
tree | 0338b92787ad50a9d673c70ff2895400d9c37d19 /perllib/FixMyStreet/App/Controller/Report/New.pm | |
parent | 9971657aaf579c37a91f546b01aaee7d96c9db38 (diff) |
limit problem body to single body if required
Add a single_body_only form value to reports that contains the name of
the only body to send the problem to. If the name doesn't match any of
the valid bodies for the report then send to all.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 82787e9da..312268f65 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -875,6 +875,7 @@ sub process_report : Private { 'partial', # 'service', # 'non_public', + 'single_body_only' ); # load the report @@ -932,7 +933,7 @@ sub process_report : Private { return 1; } - my $bodies = $c->forward('contacts_to_bodies', [ $report->category ]); + my $bodies = $c->forward('contacts_to_bodies', [ $report->category, $params{single_body_only} ]); my $body_string = join(',', map { $_->id } @$bodies) || '-1'; $report->bodies_str($body_string); @@ -982,10 +983,18 @@ sub process_report : Private { } sub contacts_to_bodies : Private { - my ($self, $c, $category) = @_; + my ($self, $c, $category, $single_body_only) = @_; my @contacts = grep { $_->category eq $category } @{$c->stash->{contacts}}; + # check that we've not indicated we only want to sent to a single body + # and if we find a matching one then only send to that. e.g. if we clicked + # on a TfL road on the map. + if ($single_body_only) { + my @contacts_filtered = grep { $_->body->name eq $single_body_only } @contacts; + @contacts = @contacts_filtered if scalar @contacts_filtered; + } + if ($c->stash->{unresponsive}{$category} || $c->stash->{unresponsive}{ALL} || !@contacts) { []; } else { |