diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index b5e5c5738..aa2e09892 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -872,7 +872,6 @@ sub process_report : Private { 'partial', # 'service', # 'non_public', - 'single_body_only' ); # load the report @@ -931,8 +930,18 @@ sub process_report : Private { return 1; } - my $bodies = $c->forward('contacts_to_bodies', [ $report->category, $params{single_body_only} ]); - my $body_string = join(',', map { $_->id } @$bodies) || '-1'; + # 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. + my $body_string = do { + if (my $single_body_only = $c->get_param('single_body_only')) { + my $body = $c->model('DB::Body')->search({ name => $single_body_only })->first; + $body ? $body->id : '-1'; + } else { + my $bodies = $c->forward('contacts_to_bodies', [ $report->category ]); + join(',', map { $_->id } @$bodies) || '-1'; + } + }; $report->bodies_str($body_string); # Record any body IDs which might have meant to match, but had no contact @@ -988,18 +997,10 @@ sub process_report : Private { } sub contacts_to_bodies : Private { - my ($self, $c, $category, $single_body_only) = @_; + my ($self, $c, $category) = @_; 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 { |