aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-10-28 14:28:50 +0000
committerDave Arter <davea@mysociety.org>2019-12-09 12:48:12 +0000
commitc78c63f25cc53332b182296163e9560849b1dd4a (patch)
tree0bd732f88f5a891b10ef45c9c71fefa5842f45c1
parent534bb6f75db411b56a7d9c3e7c7b91b4480c6999 (diff)
Add cobrand hook for overriding areas on /reports wards
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm15
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm6
3 files changed, 17 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 271513df3..4dbe0db42 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -400,9 +400,7 @@ sub ward_check : Private {
$parent_id = $c->stash->{area}->{id};
}
- my $qw = FixMyStreet::MapIt::call('area/children', [ $parent_id ],
- type => $c->cobrand->area_types_children,
- );
+ my $qw = $c->cobrand->fetch_area_children($parent_id);
my %names = map { $c->cobrand->short_name({ name => $_ }) => 1 } @wards;
my @areas;
foreach my $area (sort { $a->{name} cmp $b->{name} } values %$qw) {
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 1f2e48994..ae7be6892 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -790,6 +790,21 @@ The MaPit types this site handles
sub area_types { FixMyStreet->config('MAPIT_TYPES') || [ 'ZZZ' ] }
sub area_types_children { FixMyStreet->config('MAPIT_TYPES_CHILDREN') || [] }
+=item fetch_area_children
+
+Fetches the children of a particular MapIt area ID that match the current
+cobrand's area_types_children type.
+
+=cut
+
+sub fetch_area_children {
+ my ($self, $area_id) = @_;
+
+ return FixMyStreet::MapIt::call('area/children', $area_id,
+ type => $self->area_types_children
+ );
+}
+
=item contact_name, contact_email
Return the contact name or email for the cobranded version of the site (to be
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index 29ce67204..05d6bfcab 100644
--- a/perllib/FixMyStreet/DB/Result/Body.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -193,11 +193,7 @@ sub first_area_children {
my $cobrand = $self->result_source->schema->cobrand;
- my $children = FixMyStreet::MapIt::call('area/children', $body_area->area_id,
- type => $cobrand->area_types_children,
- );
-
- return $children;
+ return $cobrand->fetch_area_children($body_area->area_id);
}
=head2 get_cobrand_handler