aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-03-20 14:45:29 +0000
committerStruan Donald <struan@exo.org.uk>2020-03-31 09:58:58 +0100
commit0aef77167952f2ceff90e4aad27bdf871d55561e (patch)
tree115061a36fd819406045e99bfa16780471d5bc12
parent6e07f9477d0218151f80a181c7832fe73c6accac (diff)
Match body construction on Around with New setup.
On an around page on the HE cobrand, both bodies (HE and council) are listed and so when you clicked the map (not on a HE road) the not-HE code did not fire because it wasn't the only body present. But New.pm calls only return the HE body because they call munge_report_new_bodies. So it worked when you picked category/ moved pin. Around should call the munge function too so bodies is set up same as on New.pm. We need to always use the cobrand package, regardless of if it is a valid cobrand or not (for e.g. Bromley/Hounslow tests).
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm2
3 files changed, 4 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 5afca29df..af50f1883 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -231,6 +231,8 @@ sub check_and_stash_category : Private {
my $all_areas = $c->stash->{all_areas};
my @bodies = $c->model('DB::Body')->active->for_areas(keys %$all_areas)->all;
my %bodies = map { $_->id => $_ } @bodies;
+ $c->cobrand->call_hook(munge_report_new_bodies => \%bodies); # To match setup_categories_and_bodies in New.pm
+
my @list_of_names = map { $_->name } values %bodies;
my $csv = Text::CSV->new();
$csv->combine(@list_of_names);
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index a2dea1df4..951804c20 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -98,7 +98,7 @@ sub munge_report_new_bodies {
my %bodies = map { $_->name => 1 } values %$bodies;
if ( $bodies{'TfL'} ) {
# Presented categories vary if we're on/off a red route
- my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} });
+ my $tfl = FixMyStreet::Cobrand::TfL->new({ c => $self->{c} });
$tfl->munge_surrounding_london($bodies);
}
}
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 8cc7d90e0..0ba9ba9c0 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -301,7 +301,7 @@ sub munge_report_new_bodies {
my %bodies = map { $_->name => 1 } values %$bodies;
if ( $bodies{'TfL'} ) {
# Presented categories vary if we're on/off a red route
- my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} });
+ my $tfl = FixMyStreet::Cobrand::TfL->new({ c => $self->{c} });
$tfl->munge_surrounding_london($bodies);
}
}