diff options
author | Dave Arter <davea@mysociety.org> | 2019-10-18 13:58:35 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2019-12-09 12:48:12 +0000 |
commit | b150f8ac189c9caac3f9853c2c4116e9cb4db44e (patch) | |
tree | f64b6cc9623acb8d65c7e3fc078ceac029365963 | |
parent | 15b7b2d146b337894f318c3a20ea03b400c0429d (diff) |
Pre-filter ‘all reports’ by area for inspectors
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 28 | ||||
-rw-r--r-- | t/Mock/MapIt.pm | 2 | ||||
-rw-r--r-- | templates/web/base/main_nav_items.html | 18 | ||||
-rw-r--r-- | templates/web/base/navigation/_all_reports.html | 13 | ||||
-rw-r--r-- | templates/web/bexley/main_nav_items.html | 20 | ||||
-rw-r--r-- | templates/web/hounslow/main_nav_items.html | 18 | ||||
-rw-r--r-- | templates/web/isleofwight/main_nav_items.html | 17 | ||||
-rw-r--r-- | templates/web/oxfordshire/main_nav_items.html | 20 |
8 files changed, 50 insertions, 86 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 ) = @_; diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index f7dd2eb83..3b36b52f4 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -119,6 +119,8 @@ sub dispatch_request { $self->output({2650 => {parent_area => undef, id => 2650, name => "Aberdeen Council", type => "UTA"}}); } elsif ($areas eq 'GRE') { $self->output({2493 => {parent_area => undef, id => 2493, name => "Greenwich Borough Council", type => "LBO"}}); + } elsif ($areas eq 60705) { + $self->output({60705 => {parent_area => 2245, id => 60705, name => "Trowbridge", type => "CPC"}}); } }, diff --git a/templates/web/base/main_nav_items.html b/templates/web/base/main_nav_items.html index 3e7852ea8..e652f12f6 100644 --- a/templates/web/base/main_nav_items.html +++ b/templates/web/base/main_nav_items.html @@ -18,23 +18,7 @@ [%~ INCLUDE navitem always_url=1 uri='/my/planned' label=loc('Shortlist') ~%] [%~ END ~%] - -[%~ UNLESS hide_all_reports_link ~%] - [%~ - IF c.user_exists AND c.user.categories.size; - categories = c.user.categories_string | uri; - cat_suffix = "?filter_category=" _ categories; - END; - - reports_uri = '/reports'; - IF c.cobrand.council_area; - body_name = c.cobrand.council_area | uri; - reports_uri = "${reports_uri}/${body_name}"; - END; - - INCLUDE navitem uri=reports_uri label=loc('All reports') suffix=cat_suffix; - ~%] -[%~ END ~%] +[%~ INCLUDE 'navigation/_all_reports.html' ~%] [%~ IF pc; diff --git a/templates/web/base/navigation/_all_reports.html b/templates/web/base/navigation/_all_reports.html new file mode 100644 index 000000000..bcc40ed5d --- /dev/null +++ b/templates/web/base/navigation/_all_reports.html @@ -0,0 +1,13 @@ +[%~ + IF c.user_exists AND ( c.user.categories.size OR c.user.area_ids.size ); + reports_uri = '/my/inspector_redirect'; + ELSE; + reports_uri = '/reports'; + IF c.cobrand.council_area; + body_name = c.cobrand.council_area | uri; + reports_uri = "${reports_uri}/${body_name}"; + END; + END; + + INCLUDE navitem uri=reports_uri label=loc('All reports'); +~%] diff --git a/templates/web/bexley/main_nav_items.html b/templates/web/bexley/main_nav_items.html index 3b948d043..9f85db522 100644 --- a/templates/web/bexley/main_nav_items.html +++ b/templates/web/bexley/main_nav_items.html @@ -7,23 +7,7 @@ [%~ ELSE ~%] [%~ INCLUDE navitem uri='/' label=loc('Report a problem') attrs='class="report-a-problem-btn"' ~%] [%~ END ~%] - -[%~ UNLESS hide_all_reports_link ~%] - [%~ - IF c.user_exists AND c.user.categories.size; - categories = c.user.categories_string | uri; - cat_suffix = "?filter_category=" _ categories; - END; - - reports_uri = '/reports'; - IF c.cobrand.council_area; - body_name = c.cobrand.council_area | uri; - reports_uri = "${reports_uri}/${body_name}"; - END; - - INCLUDE navitem uri=reports_uri label=loc('All reports') suffix=cat_suffix; - ~%] -[%~ END ~%] +[%~ INCLUDE 'navigation/_all_reports.html' ~%] [%~ IF pc; @@ -37,7 +21,7 @@ [%~ INCLUDE navitem uri='/faq' label=loc('Help') ~%] [%~ UNLESS hide_privacy_link ~%] - [%~ INCLUDE navitem uri='/privacy' label=loc('Privacy') liattrs='class="nav-menu__item--privacy"' ~%] + [%~ INCLUDE navitem uri=c.cobrand.privacy_policy_url label=loc('Privacy') liattrs='class="nav-menu__item--privacy"' ~%] [%~ END ~%] [%~ IF c.user_exists ~%] diff --git a/templates/web/hounslow/main_nav_items.html b/templates/web/hounslow/main_nav_items.html index b5c04c4c7..6bb323abc 100644 --- a/templates/web/hounslow/main_nav_items.html +++ b/templates/web/hounslow/main_nav_items.html @@ -18,23 +18,7 @@ [%~ INCLUDE navitem always_url=1 uri='/my/planned' label=loc('Shortlist') ~%] [%~ END ~%] - -[%~ UNLESS hide_all_reports_link ~%] - [%~ - IF c.user_exists AND c.user.categories.size; - categories = c.user.categories_string | uri; - cat_suffix = "?filter_category=" _ categories; - END; - - reports_uri = '/reports'; - IF c.cobrand.council_area; - body_name = c.cobrand.council_area | uri; - reports_uri = "${reports_uri}/${body_name}"; - END; - - INCLUDE navitem uri=reports_uri label=loc('All reports') suffix=cat_suffix; - ~%] -[%~ END ~%] +[%~ INCLUDE 'navigation/_all_reports.html' ~%] [%~ IF pc; diff --git a/templates/web/isleofwight/main_nav_items.html b/templates/web/isleofwight/main_nav_items.html index 5b794a99d..81df6e599 100644 --- a/templates/web/isleofwight/main_nav_items.html +++ b/templates/web/isleofwight/main_nav_items.html @@ -22,22 +22,7 @@ [%~ INCLUDE navitem always_url=1 uri='/admin/triage' label=loc('Awaiting triage') ~%] [%~ END ~%] -[%~ UNLESS hide_all_reports_link ~%] - [%~ - IF c.user_exists AND c.user.categories.size; - categories = c.user.categories_string | uri; - cat_suffix = "?filter_category=" _ categories; - END; - - reports_uri = '/reports'; - IF c.cobrand.council_area; - body_name = c.cobrand.council_area | uri; - reports_uri = "${reports_uri}/${body_name}"; - END; - - INCLUDE navitem uri=reports_uri label=loc('All reports') suffix=cat_suffix; - ~%] -[%~ END ~%] +[%~ INCLUDE 'navigation/_all_reports.html' ~%] [%~ IF pc; diff --git a/templates/web/oxfordshire/main_nav_items.html b/templates/web/oxfordshire/main_nav_items.html index a57dd1aad..8ebe48450 100644 --- a/templates/web/oxfordshire/main_nav_items.html +++ b/templates/web/oxfordshire/main_nav_items.html @@ -10,23 +10,7 @@ [%~ INCLUDE navitem always_url=1 uri='/my/planned' label=loc('Shortlist') ~%] [%~ END ~%] - -[%~ UNLESS hide_all_reports_link ~%] - [%~ - IF c.user_exists AND c.user.categories.size; - categories = c.user.categories.join(",") | uri; - cat_suffix = "?filter_category=" _ categories; - END; - - reports_uri = '/reports'; - IF c.cobrand.council_area; - body_name = c.cobrand.council_area | uri; - reports_uri = "${reports_uri}/${body_name}"; - END; - - INCLUDE navitem uri=reports_uri label=loc('All reports') suffix=cat_suffix; - ~%] -[%~ END ~%] +[%~ INCLUDE 'navigation/_all_reports.html' ~%] [%~ IF pc; @@ -40,7 +24,7 @@ [%~ INCLUDE navitem uri='/faq' label=loc('Help') ~%] [%~ UNLESS hide_privacy_link ~%] - [%~ INCLUDE navitem uri='/privacy' label=loc('Privacy') liattrs='class="nav-menu__item--privacy"' ~%] + [%~ INCLUDE navitem uri=c.cobrand.privacy_policy_url label=loc('Privacy') liattrs='class="nav-menu__item--privacy"' ~%] [%~ END ~%] [%~ IF c.user_exists AND c.cobrand.admin_allow_user(c.user) ~%] |