diff options
author | Marius Halden <marius.h@lden.org> | 2020-09-29 14:23:52 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2020-09-29 14:23:52 +0200 |
commit | a27ce1524d801d2742a2bdb6ec1da45126d64353 (patch) | |
tree | 64123c4e17dc1776aa0a7cd65ee01d49d3e7d978 /perllib/FixMyStreet/App/Controller/My.pm | |
parent | 377bd96aab7cad3434185c30eb908c9da447fe40 (diff) | |
parent | 2773c60226b9370fe8ee00f7b205b571bb87c3b5 (diff) |
Merge tag 'v3.0.1' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/My.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index ed890ad82..3328caac0 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -45,6 +45,34 @@ sub my : Path : Args(0) { $c->forward('setup_page_data'); } + +=head2 inspector_redirect + +A convenience redirect to the /reports/ page pre-filtered to the +inspector's body, areas & categories. + +=cut + +sub inspector_redirect : Local : Args(0) { + my ( $self, $c ) = @_; + + my $categories = $c->user->categories_string; + my $area_ids = $c->user->area_ids || []; + my $body = $c->user->from_body; + + $c->detach('/page_error_404_not_found') unless $body && ($categories || @$area_ids); + + if (@$area_ids) { + my $ids_string = join ",", @$area_ids; + my $areas = mySociety::MaPit::call('areas', [ $ids_string ]); + $c->stash->{wards} = [ values %$areas ]; + } + + $c->stash->{body} = $body; + $c->set_param('filter_category', $categories) if $categories; + $c->detach('/reports/redirect_body'); +} + sub planned : Local : Args(0) { my ( $self, $c ) = @_; @@ -161,11 +189,12 @@ sub setup_page_data : Private { my @categories = $c->stash->{problems_rs}->search({ state => [ FixMyStreet::DB::Result::Problem->visible_states() ], }, { - columns => [ 'category' ], + columns => [ 'category', 'bodies_str', 'extra' ], distinct => 1, order_by => [ 'category' ], } )->all; $c->stash->{filter_categories} = \@categories; + $c->forward('/report/stash_category_groups', [ \@categories ]) if $c->cobrand->enable_category_groups; my $pins = $c->stash->{pins}; FixMyStreet::Map::display_map( |