aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2014-05-16 12:05:23 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2014-05-16 14:07:53 +0100
commitbf062b508081521201cf315f483b7aee3a6a0c7b (patch)
tree01e4284d97b31c6d7fdb9a3a0c7be50d08bb4d26
parent825a60275017e7cbf1bab54d350e9019102ef348 (diff)
Add MAPIT_GENERATION variable, to pin whitelist.
Otherwise, when MapIt Global is updated, the 'point' lookup, as it only returns the current generation by default, might no longer return the areas present in the whitelist.
-rw-r--r--conf/general.yml-example5
-rw-r--r--perllib/FixMyStreet/App/Controller/Council.pm11
-rw-r--r--t/cobrand/zurich.t4
-rw-r--r--templates/web/default/admin/config_page.html1
4 files changed, 17 insertions, 4 deletions
diff --git a/conf/general.yml-example b/conf/general.yml-example
index f5fb89b64..0704fdb52 100644
--- a/conf/general.yml-example
+++ b/conf/general.yml-example
@@ -74,9 +74,12 @@ 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.
+# IDs here in a list that FixMyStreet should recognise, along with the MapIt
+# generation those IDs are in.
# MAPIT_ID_WHITELIST: [ 240838, 246176, 246733 ]
+# MAPIT_GENERATION: 2
MAPIT_ID_WHITELIST: []
+MAPIT_GENERATION: 0
# 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
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index ceec04027..8a174c254 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -53,10 +53,16 @@ sub load_and_check_areas : Private {
my $short_longitude = Utils::truncate_coordinate($longitude);
my $all_areas;
+
+ my %params;
+ $params{generation} = $c->config->{MAPIT_GENERATION}
+ if $c->config->{MAPIT_GENERATION};
+
if ( $c->stash->{fetch_all_areas} ) {
my %area_types = map { $_ => 1 } @$area_types;
$all_areas =
- mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude" );
+ mySociety::MaPit::call( 'point',
+ "4326/$short_longitude,$short_latitude", %params );
$c->stash->{all_areas_mapit} = $all_areas;
$all_areas = {
map { $_ => $all_areas->{$_} }
@@ -65,7 +71,8 @@ sub load_and_check_areas : Private {
};
} else {
$all_areas =
- mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude",
+ mySociety::MaPit::call( 'point',
+ "4326/$short_longitude,$short_latitude", %params,
type => $area_types );
}
if ($all_areas->{error}) {
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index e97891b91..16c0b77f8 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -565,7 +565,8 @@ subtest "phone number is mandatory" => sub {
MAPIT_TYPES => [ 'O08' ],
MAPIT_URL => 'http://global.mapit.mysociety.org/',
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_ID_WHITELIST => [ 423017 ],
+ MAPIT_ID_WHITELIST => [ 274456 ],
+ MAPIT_GENERATION => 2,
}, sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
$mech->get_ok( '/report/new?lat=47.381817&lon=8.529156' );
@@ -581,6 +582,7 @@ subtest "phone number is not mandatory for reports from mobile apps" => sub {
MAPIT_URL => 'http://global.mapit.mysociety.org/',
ALLOWED_COBRANDS => [ 'zurich' ],
MAPIT_ID_WHITELIST => [ 423017 ],
+ MAPIT_GENERATION => 4,
}, sub {
$mech->post_ok( '/report/new/mobile?lat=47.381817&lon=8.529156' , {
service => 'iPhone',
diff --git a/templates/web/default/admin/config_page.html b/templates/web/default/admin/config_page.html
index f198de2af..83300e4db 100644
--- a/templates/web/default/admin/config_page.html
+++ b/templates/web/default/admin/config_page.html
@@ -84,6 +84,7 @@ running version <strong>[% git_version || 'unknown' %]</strong>.
[% INCLUDE with_cobrand value="MAPIT_TYPES"
cob = c.cobrand.area_types %]
[% INCLUDE just_value value="MAPIT_ID_WHITELIST" %]
+[% INCLUDE just_value value="MAPIT_GENERATION" %]
[% INCLUDE with_cobrand value="MAPIT_TYPES_CHILDREN"
cob = c.cobrand.area_types_children %]