aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-04-16 19:48:07 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-04-17 10:25:42 +0100
commit524b44db045789941e0248f599c409d968a759e7 (patch)
tree1f8c961bb7ec419644f26c18519bbffb7b5cd33f
parent470a7825dfe2ad0adede647475186351d9e07cf7 (diff)
[Bromley] Fix heatmap category filter.
As it has switched to using category groups, the special subcategory code needs updating to update the correct variable.
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm27
-rw-r--r--t/cobrand/bromley.t2
2 files changed, 17 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 73d5f94bf..8f82817a8 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -132,20 +132,25 @@ sub tweak_all_reports_map {
# A place where this can happen
return unless $c->action eq 'dashboard/heatmap';
- # Bromley only subcategory stuff
+ # Bromley uses an extra attribute question to store 'subcategory',
+ # rather than group/category, but wants this extra question to act
+ # like a subcategory e.g. in the dashboard filter here.
my %subcats = $self->subcategories;
- my $filter = $c->stash->{filter_categories};
- my @new_contacts;
- foreach (@$filter) {
- push @new_contacts, $_;
- foreach (@{$subcats{$_->id}}) {
- push @new_contacts, {
- category => $_->{key},
- category_display => (" " x 4) . $_->{name},
- };
+ my $groups = $c->stash->{category_groups};
+ foreach (@$groups) {
+ my $filter = $_->{categories};
+ my @new_contacts;
+ foreach (@$filter) {
+ push @new_contacts, $_;
+ foreach (@{$subcats{$_->id}}) {
+ push @new_contacts, {
+ category => $_->{key},
+ category_display => (" " x 4) . $_->{name},
+ };
+ }
}
+ $_->{categories} = \@new_contacts;
}
- $c->stash->{filter_categories} = \@new_contacts;
if (!%{$c->stash->{filter_category}}) {
my $cats = $c->user->categories;
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 02ec8750e..71180cd3e 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -233,7 +233,7 @@ subtest 'check heatmap page' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => 'bromley',
MAPIT_URL => 'http://mapit.uk/',
- COBRAND_FEATURES => { heatmap => { bromley => 1 } },
+ COBRAND_FEATURES => { category_groups => { bromley => 1 }, heatmap => { bromley => 1 } },
}, sub {
$mech->log_in_ok($user->email);
$mech->get_ok('/dashboard/heatmap?end_date=2018-12-31');