diff options
author | Struan Donald <struan@exo.org.uk> | 2018-09-10 12:40:58 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-09-12 14:21:49 +0100 |
commit | 96cf649c4e7e7c9a6db8e129d48657d7e2e207ce (patch) | |
tree | dfdb488728f10532daa6288d2ad5506092a0ed05 | |
parent | 07393fcc9279aac9492f1a8e528cae2cced7bb44 (diff) |
move body stats page code to own method
Enables this to be used in cobrand hooks for reports data
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 9826a8945..ade04fc7c 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -40,14 +40,7 @@ sub index : Path : Args(0) { $c->detach( 'redirect_body' ); } - if (my $body = $c->get_param('body')) { - $body = $c->model('DB::Body')->find( { id => $body } ); - if ($body) { - $body = $c->cobrand->short_name($body); - $c->res->redirect("/reports/$body"); - $c->detach; - } - } + $c->forward('display_body_stats'); my $dashboard = $c->forward('load_dashboard_data'); @@ -82,6 +75,24 @@ sub index : Path : Args(0) { $c->response->header('Cache-Control' => 'max-age=3600'); } +=head2 display_body_stats + +Show the stats for a body if body param is set. + +=cut + +sub display_body_stats : Private { + my ( $self, $c ) = @_; + if (my $body = $c->get_param('body')) { + $body = $c->model('DB::Body')->find( { id => $body } ); + if ($body) { + $body = $c->cobrand->short_name($body); + $c->res->redirect("/reports/$body"); + $c->detach; + } + } +} + =head2 body Show the summary page for a particular body. |