aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/My.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-10-18 13:58:35 +0100
committerDave Arter <davea@mysociety.org>2019-12-09 12:48:12 +0000
commitb150f8ac189c9caac3f9853c2c4116e9cb4db44e (patch)
treef64b6cc9623acb8d65c7e3fc078ceac029365963 /perllib/FixMyStreet/App/Controller/My.pm
parent15b7b2d146b337894f318c3a20ea03b400c0429d (diff)
Pre-filter ‘all reports’ by area for inspectors
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/My.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index b181acd04..efb770f70 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 ) = @_;