diff options
-rw-r--r-- | perllib/Cobrands/Barnet/Util.pm | 14 | ||||
-rwxr-xr-x | web/alert.cgi | 2 | ||||
-rwxr-xr-x | web/index.cgi | 6 |
3 files changed, 14 insertions, 8 deletions
diff --git a/perllib/Cobrands/Barnet/Util.pm b/perllib/Cobrands/Barnet/Util.pm index 8eed687de..3cc60117f 100644 --- a/perllib/Cobrands/Barnet/Util.pm +++ b/perllib/Cobrands/Barnet/Util.pm @@ -15,6 +15,7 @@ use strict; use Carp; use URI::Escape; use mySociety::Web qw(ent); +use mySociety::VotingArea; sub new { my $class = shift; @@ -63,13 +64,20 @@ sub enter_postcode_text { =item council_check COUNCILS QUERY CONTEXT -Return a boolean indicating whether the councils for the location passed any -extra checks defined by the cobrand ousing data in the query +Return a boolean indicating whether COUNCILS are okay for the location +in the QUERY, and an error message appropriate to the CONTEXT. =cut sub council_check { - my ($self, $councils, $q, $context) = @_; + my ($self, $params, $q, $context) = @_; + my $councils; + if ($params->{all_councils}) { + $councils = $params->{all_councils}; + } elsif ($params->{e}) { + my $parent_types = $mySociety::VotingArea::council_parent_types; + $councils = mySociety::MaPit::call('point', "27700/$params->{e},$params->{n}", type => $parent_types); + } my $council_match = defined $councils->{2489}; if ($council_match) { return 1; diff --git a/web/alert.cgi b/web/alert.cgi index 5a7aef1fc..108a02683 100755 --- a/web/alert.cgi +++ b/web/alert.cgi @@ -106,7 +106,7 @@ sub alert_list { my $areas = mySociety::MaPit::call('point', "27700/$e,$n", type => \@types); my $cobrand = Page::get_cobrand($q); - my ($success, $error_msg) = Cobrand::council_check($cobrand, $areas, $q, 'alert'); + my ($success, $error_msg) = Cobrand::council_check($cobrand, { all_councils => $areas }, $q, 'alert'); if (!$success){ return alert_front_page($q, $error_msg); } diff --git a/web/index.cgi b/web/index.cgi index a3ac1296c..4ac20ad90 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -513,7 +513,7 @@ sub display_form { my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types); # Let cobrand do a check - my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'submit_problem'); + my ($success, $error_msg) = Cobrand::council_check($cobrand, { all_councils => $all_councils }, $q, 'submit_problem'); if (!$success){ return front_page($q, $error_msg); } @@ -808,9 +808,7 @@ sub display_location { } # Check this location is okay to be displayed for the cobrand - my $parent_types = $mySociety::VotingArea::council_parent_types; - my $all_councils = mySociety::MaPit::call('point', "27700/$easting,$northing", type => $parent_types); - my ($success, $error_msg) = Cobrand::council_check($cobrand, $all_councils, $q, 'display_location'); + my ($success, $error_msg) = Cobrand::council_check($cobrand, { e => $easting, n => $northing }, $all_councils, $q, 'display_location'); return front_page($q, $error_msg) unless $success; # Deal with pin hiding/age |