diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-04-13 14:29:56 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-04-13 14:35:58 +0100 |
commit | 112ab20142f7f79d4ffff557b95c53406ad79bd9 (patch) | |
tree | 20f32e6faa1449c6345a8ffeb428dfc440cfddee /perllib/FixMyStreet | |
parent | cfe97d706f5cb7b3f3ca6d9227a872a7e50d97b2 (diff) |
Fix issue with categories with regex characters.
As the templates were using `grep`, they failed to match on a category
such as "Footpaths (right of way)". Changing the stash variables to be
hashes instead of lists makes checking for a key simpler. Fixes #1688.
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 2 |
5 files changed, 9 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index c49cafe7d..1f3307710 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -733,7 +733,7 @@ sub report_edit : Path('report_edit') : Args(1) { } } - $c->stash->{categories} = $c->forward('categories_for_point'); + $c->forward('categories_for_point'); if ( $c->cobrand->moniker eq 'zurich' ) { my $done = $c->cobrand->admin_report_edit(); @@ -909,7 +909,8 @@ sub categories_for_point : Private { # Remove the "Pick a category" option shift @{$c->stash->{category_options}} if @{$c->stash->{category_options}}; - return $c->stash->{category_options}; + $c->stash->{categories} = $c->stash->{category_options}; + $c->stash->{categories_hash} = { map { $_ => 1 } @{$c->stash->{category_options}} }; } sub templates : Path('templates') : Args(0) { diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 96854b17b..1fe35d0a3 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -182,7 +182,7 @@ sub display_location : Private { my ( $on_map_all, $on_map, $nearby, $distance ) = FixMyStreet::Map::map_features( $c, latitude => $latitude, longitude => $longitude, - interval => $interval, categories => $c->stash->{filter_category}, + interval => $interval, categories => [ keys %{$c->stash->{filter_category}} ], states => $c->stash->{filter_problem_states}, order => $c->stash->{sort_order}, ); @@ -264,8 +264,8 @@ sub check_and_stash_category : Private { my %categories_mapped = map { $_ => 1 } @categories; my $categories = [ $c->get_param_list('filter_category', 1) ]; - my @valid_categories = grep { $_ && $categories_mapped{$_} } @$categories; - $c->stash->{filter_category} = \@valid_categories; + my %valid_categories = map { $_ => 1 } grep { $_ && $categories_mapped{$_} } @$categories; + $c->stash->{filter_category} = \%valid_categories; } =head2 /ajax diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index ffcdf829d..77711f807 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -111,7 +111,7 @@ sub get_problems : Private { my $categories = [ $c->get_param_list('filter_category', 1) ]; if ( @$categories ) { $params->{category} = $categories; - $c->stash->{filter_category} = $categories; + $c->stash->{filter_category} = { map { $_ => 1 } @$categories }; } my $rows = 50; diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index fe7576893..ad2702460 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -306,7 +306,7 @@ sub inspect : Private { my $problem = $c->stash->{problem}; my $permissions = $c->stash->{_permissions}; - $c->stash->{categories} = $c->forward('/admin/categories_for_point'); + $c->forward('/admin/categories_for_point'); $c->stash->{report_meta} = { map { $_->{name} => $_ } @{ $c->stash->{problem}->get_extra_fields() } }; my %category_body = map { $_->category => $_->body_id } map { $_->contacts->all } values %{$problem->bodies}; diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 69a2ddb0f..bb5b13b61 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -137,7 +137,7 @@ sub ward : Path : Args(2) { } )->all; @categories = map { $_->category } @categories; $c->stash->{filter_categories} = \@categories; - $c->stash->{filter_category} = [ $c->get_param_list('filter_category', 1) ]; + $c->stash->{filter_category} = { map { $_ => 1 } $c->get_param_list('filter_category', 1) }; my $pins = $c->stash->{pins}; |