diff options
author | Dave Arter <davea@mysociety.org> | 2015-03-20 18:17:44 +0000 |
---|---|---|
committer | Steven Day <steve@mysociety.org> | 2015-06-29 12:43:02 +0100 |
commit | d5b603e23557d255f7d930b30860b5c97951f631 (patch) | |
tree | 708d39b136da05e61c34513b9db5ea727c7b9452 | |
parent | a76bd2ab4910aedd589b12ee857091d11b9db30b (diff) |
Make load_and_group_problems respect status/category query params
This allows the /reports page to be filtered using the status/category
dropdowns.
This is implemented in a manner that means the t/c params will override
status/category.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 17 |
2 files changed, 16 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 9d86975c6..dbba93df2 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -167,7 +167,7 @@ sub display_location : Private { my $states = $c->cobrand->on_map_default_states; $c->stash->{filter_status} = $c->cobrand->on_map_default_status; - my $status = $c->req->param('status'); + my $status = $c->req->param('status') || ''; if ( !defined $states || $status eq 'all' ) { $states = FixMyStreet::DB::Result::Problem->visible_states(); $c->stash->{filter_status} = 'all'; diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 8d7a7acbd..4b4a11c8b 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -375,11 +375,24 @@ sub load_and_group_problems : Private { my $page = $c->req->params->{p} || 1; my $type = $c->req->params->{t} || 'all'; - my $category = $c->req->params->{c} || ''; + my $category = $c->req->params->{c} || $c->req->params->{category} || ''; + + # Unlike the 't' query param, 'status' isn't affected by + # the age of a report, so treat the filtering separately. + # If 't' is specified, it will override 'status'. + my $states = $c->cobrand->on_map_default_states; + my $status = $c->req->param('status') || ''; + if ( !defined $states || $status eq 'all' ) { + $states = FixMyStreet::DB::Result::Problem->visible_states(); + } elsif ( $status eq 'open' ) { + $states = FixMyStreet::DB::Result::Problem->open_states(); + } elsif ( $status eq 'fixed' ) { + $states = FixMyStreet::DB::Result::Problem->fixed_states(); + } my $where = { non_public => 0, - state => [ FixMyStreet::DB::Result::Problem->visible_states() ] + state => [ keys %$states ] }; my $not_open = [ FixMyStreet::DB::Result::Problem::fixed_states(), FixMyStreet::DB::Result::Problem::closed_states() ]; |