diff options
-rw-r--r-- | perllib/Cobrands/Barnet/Util.pm | 14 | ||||
-rw-r--r-- | perllib/Page.pm | 3 | ||||
-rw-r--r-- | templates/emails/submit-council | 4 | ||||
-rwxr-xr-x | web-admin/index.cgi | 4 | ||||
-rwxr-xr-x | web/alert.cgi | 2 | ||||
-rwxr-xr-x | web/index.cgi | 6 | ||||
-rwxr-xr-x | web/reports.cgi | 4 |
7 files changed, 27 insertions, 10 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/perllib/Page.pm b/perllib/Page.pm index fe6a6e8cb..127fad11b 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -918,6 +918,9 @@ sub mapit_check_error { return $location->{error}; } my $island = $location->{coordsyst}; + if (!$island) { + return _("Sorry, that appears to be a Crown dependency postcode, which we don't cover."); + } if ($island eq 'I') { return _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region."); } diff --git a/templates/emails/submit-council b/templates/emails/submit-council index 38fbcc476..d3a4a0c64 100644 --- a/templates/emails/submit-council +++ b/templates/emails/submit-council @@ -21,6 +21,10 @@ Email: <?=$values['email']?> Details: <?=$values['detail']?> +Easting: <?=$values['easting']?> + +Northing: <?=$values['northing']?> + <?=$values['closest_address']?>---------- Replies to this email will go to the user who submitted the problem. diff --git a/web-admin/index.cgi b/web-admin/index.cgi index b7946d600..2868cf2d6 100755 --- a/web-admin/index.cgi +++ b/web-admin/index.cgi @@ -309,7 +309,7 @@ sub admin_council_contacts ($$) { # Example postcode, link to list of problem reports my $links_html; my $example_postcode = mySociety::MaPit::call('area/example_postcode', $area_id); - if ($example_postcode) { + if ($example_postcode && ! ref $example_postcode) { $links_html .= $q->a({ href => mySociety::Config::get('BASE_URL') . '/?pc=' . $q->escape($example_postcode) }, "Example postcode " . $example_postcode) . " | "; } @@ -390,7 +390,7 @@ sub admin_council_edit ($$$) { # Example postcode my $example_postcode = mySociety::MaPit::call('area/example_postcode', $area_id); - if ($example_postcode) { + if ($example_postcode && ! ref $example_postcode) { print $q->p("Example postcode: ", $q->a({ href => mySociety::Config::get('BASE_URL') . '/?pc=' . $q->escape($example_postcode) }, $example_postcode)); 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..dcbec5a1c 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 }, $q, 'display_location'); return front_page($q, $error_msg) unless $success; # Deal with pin hiding/age diff --git a/web/reports.cgi b/web/reports.cgi index bc418db7c..4faee63f9 100755 --- a/web/reports.cgi +++ b/web/reports.cgi @@ -67,6 +67,10 @@ sub main { } } elsif ($q_council =~ /^\d+$/) { my $va_info = mySociety::MaPit::call('area', $q_council); + if ($va_info->{error}) { + print $q->redirect($base_url . '/reports'); + return; + } $area_name = $va_info->{name}; print $q->redirect($base_url . '/reports/' . Page::short_name($area_name)); return; |