aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-05-02 20:23:27 +0100
committerMatthew Somerville <matthew@mysociety.org>2013-05-02 20:48:05 +0100
commitba28a5fcd63144ec85f7a9ba440abc3306299039 (patch)
treef8fd158ef9ab30fd7e6bddeccb4387772e47bb8e
parent9b6a6fd63daacf67cddb4f5ab7bbcd0375082696 (diff)
Add MAPIT_ID_WHITELIST configuration option.
This allows someone to restrict FixMyStreet's usage to specific MapIt IDs rather than a whole MapIt type. This is currently most useful with Global MapIt as you probably don't want e.g. all the O04s in the world for your installation.
-rw-r--r--conf/general.yml-example6
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm12
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm10
4 files changed, 20 insertions, 14 deletions
diff --git a/conf/general.yml-example b/conf/general.yml-example
index 4a06a2aff..d30c494ca 100644
--- a/conf/general.yml-example
+++ b/conf/general.yml-example
@@ -72,6 +72,12 @@ GEO_CACHE: '../cache/'
MAPIT_URL: ''
MAPIT_TYPES: [ 'ZZZ' ]
+# If you are using global MapIt, you might want to restrict FixMyStreet usage
+# to only one or more areas, rather than all O04, for example. Provide MapIt
+# IDs here in a list that FixMyStreet should recognise.
+# MAPIT_ID_WHITELIST: [ 240838, 246176, 246733 ]
+MAPIT_ID_WHITELIST: []
+
# If your MapIt has the concept of council wards (subareas of councils, where
# people can sign up for alerts, but not report things), then you can give the
# MapIt type codes for them here.
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index f69e9ea23..84a406a97 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -278,8 +278,10 @@ sub body_form_dropdowns : Private {
my ( $self, $c ) = @_;
my $areas;
- if ($c->cobrand->moniker eq 'zurich') {
- $areas = mySociety::MaPit::call('areas', 274456);
+ my $whitelist = $c->config->{MAPIT_ID_WHITELIST};
+
+ if ( $whitelist && ref $whitelist eq 'ARRAY' && @$whitelist ) {
+ $areas = mySociety::MaPit::call('areas', $whitelist);
} else {
$areas = mySociety::MaPit::call('areas', $c->cobrand->area_types);
}
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 257d9ec24..96b3625a8 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -562,8 +562,16 @@ Remove areas whose reports go to another area (XXX)
=cut
sub remove_redundant_areas {
- my $self = shift;
- my $all_areas = shift;
+ my $self = shift;
+ my $all_areas = shift;
+
+ my $whitelist = FixMyStreet->config('MAPIT_ID_WHITELIST');
+ return unless $whitelist && ref $whitelist eq 'ARRAY' && @$whitelist;
+
+ my %whitelist = map { $_ => 1 } @$whitelist;
+ foreach (keys %$all_areas) {
+ delete $all_areas->{$_} unless $whitelist{$_};
+ }
}
=item short_name
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index d69fdebd2..9c725e7aa 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -103,16 +103,6 @@ sub updates_as_hashref {
return $hashref;
}
-sub remove_redundant_areas {
- my $self = shift;
- my $all_areas = shift;
-
- # Remove all except Zurich
- foreach (keys %$all_areas) {
- delete $all_areas->{$_} unless $_ eq 274456;
- }
-}
-
sub show_unconfirmed_reports {
1;
}