aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rwxr-xr-xweb/alert.cgi3
-rwxr-xr-xweb/index.cgi35
-rwxr-xr-xweb/questionnaire.cgi1
-rwxr-xr-xweb/reports.cgi28
-rwxr-xr-xweb/rss.cgi2
5 files changed, 28 insertions, 41 deletions
diff --git a/web/alert.cgi b/web/alert.cgi
index 59b6607a4..d6cff7ff3 100755
--- a/web/alert.cgi
+++ b/web/alert.cgi
@@ -104,13 +104,12 @@ sub alert_list {
my @types = (@$mySociety::VotingArea::council_parent_types, @$mySociety::VotingArea::council_child_types);
my %councils = map { $_ => 1 } @$mySociety::VotingArea::council_parent_types;
- my $areas = mySociety::MaPit::get_voting_areas_by_location({easting=>$e, northing=>$n}, 'polygon', \@types);
+ 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');
if (!$success){
return alert_front_page($q, $error_msg);
}
- $areas = mySociety::MaPit::get_voting_areas_info([ keys %$areas ]);
return alert_front_page($q, _('That location does not appear to be covered by a council, perhaps it is offshore - please try somewhere more specific.')) if keys %$areas == 0;
diff --git a/web/index.cgi b/web/index.cgi
index e39dd8921..563465c37 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -306,10 +306,7 @@ sub submit_problem {
my $areas;
if ($input{easting} && $input{northing}) {
- $areas = mySociety::MaPit::get_voting_areas_by_location(
- { easting=>$input{easting}, northing=>$input{northing} },
- 'polygon', [qw(WMC CTY CED DIS DIW MTD MTW COI COP LGD LGE UTA UTE UTW LBO LBW LAC SPC WAC NIE)]
- );
+ $areas = mySociety::MaPit::call('point', "27700/$input{easting},$input{northing}");
if ($input{council} =~ /^[\d,]+(\|[\d,]+)?$/) {
my $no_details = $1 || '';
my %va = map { $_ => 1 } @$mySociety::VotingArea::council_parent_types;
@@ -515,9 +512,7 @@ sub display_form {
$parent_types = [qw(DIS LBO MTD UTA LGD COI)] # No CTY
if $q->{site} eq 'emptyhomes';
# XXX: I think we want in_gb_locale around the next line, needs testing
- my $all_councils = mySociety::MaPit::get_voting_areas_by_location(
- { easting => $easting, northing => $northing },
- 'polygon', $parent_types);
+ 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');
@@ -531,17 +526,15 @@ sub display_form {
# Norwich is responsible for everything in its areas, no Norfolk
delete $all_councils->{2233} if $all_councils->{2391};
- $all_councils = [ keys %$all_councils ];
return display_location($q, _('That spot does not appear to be covered by a council.
If you have tried to report an issue past the shoreline, for example,
-please specify the closest point on land.')) unless @$all_councils;
- my $areas_info = mySociety::MaPit::get_voting_areas_info($all_councils);
+please specify the closest point on land.')) unless %$all_councils;
# Look up categories for this council or councils
my $category = '';
my (%council_ok, @categories);
my $categories = select_all("select area_id, category from contacts
- where deleted='f' and area_id in (" . join(',', @$all_councils) . ')');
+ where deleted='f' and area_id in (" . join(',', keys %$all_councils) . ')');
if ($q->{site} ne 'emptyhomes') {
@$categories = sort { $a->{category} cmp $b->{category} } @$categories;
foreach (@$categories) {
@@ -574,7 +567,7 @@ please specify the closest point on land.')) unless @$all_councils;
# Work out what help text to show, depending on whether we have council details
my @councils = keys %council_ok;
my $details;
- if (@councils == @$all_councils) {
+ if (@councils == scalar keys %$all_councils) {
$details = 'all';
} elsif (@councils == 0) {
$details = 'none';
@@ -629,7 +622,7 @@ If this is not the correct location, simply click on the map again. '));
$vars{page_heading} = $q->h1(_('Reporting a problem'));
if ($details eq 'all') {
- my $council_list = join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils);
+ my $council_list = join('</strong> or <strong>', map { $_->{name} } values %$all_councils);
if ($q->{site} eq 'emptyhomes'){
$vars{text_help} = '<p>' . sprintf(_('All the information you provide here will be sent to <strong>%s</strong>.
On the site, we will show the subject and details of the problem, plus your
@@ -639,18 +632,18 @@ name if you give us permission.'), $council_list);
The subject and details of the problem will be public, plus your
name if you give us permission.'), $council_list);
}
- $vars{text_help} .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">';
+ $vars{text_help} .= '<input type="hidden" name="council" value="' . join(',', keys %$all_councils) . '">';
} elsif ($details eq 'some') {
my $e = Cobrand::contact_email($cobrand);
my %councils = map { $_ => 1 } @councils;
my @missing;
- foreach (@$all_councils) {
+ foreach (keys %$all_councils) {
push @missing, $_ unless $councils{$_};
}
my $n = @missing;
- my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing);
+ my $list = join(' or ', map { $all_councils->{$_}->{name} } @missing);
$vars{text_help} = '<p>All the information you provide here will be sent to <strong>'
- . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils)
+ . join('</strong> or <strong>', map { $all_councils->{$_}->{name} } @councils)
. '</strong>. The subject and details of the problem will be public, plus your
name if you give us permission.';
$vars{text_help} .= ' We do <strong>not</strong> yet have details for the other council';
@@ -661,8 +654,8 @@ problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>.";
. '|' . join(',', @missing) . '">';
} else {
my $e = Cobrand::contact_email($cobrand);
- my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils);
- my $n = @$all_councils;
+ my $list = join(' or ', map { $_->{name} } values %$all_councils);
+ my $n = scalar keys %$all_councils;
if ($q->{site} ne 'emptyhomes') {
$vars{text_help} = '<p>We do not yet have details for the council';
$vars{text_help} .= ($n>1) ? 's that cover' : ' that covers';
@@ -812,9 +805,7 @@ sub display_location {
return front_page($q, $error) if ($error);
my $parent_types = $mySociety::VotingArea::council_parent_types;
if ($easting && $northing) {
- my $all_councils = mySociety::MaPit::get_voting_areas_by_location(
- { easting => $easting, northing => $northing },
- 'polygon', $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');
if (!$success){
return front_page($q, $error_msg);
diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi
index f7b7df0e1..1da410b80 100755
--- a/web/questionnaire.cgi
+++ b/web/questionnaire.cgi
@@ -14,7 +14,6 @@ use Error qw(:try);
use CrossSell;
use mySociety::AuthToken;
use mySociety::Locale;
-use mySociety::MaPit;
use mySociety::Web qw(ent);
sub main {
diff --git a/web/reports.cgi b/web/reports.cgi
index 6c5796079..eb7f67b27 100755
--- a/web/reports.cgi
+++ b/web/reports.cgi
@@ -33,28 +33,27 @@ sub main {
my ($one_council, $area_type, $area_name);
if ($q_council =~ /^(\d\d)([a-z]{2})?([a-z]{2})?$/i) {
- my $va_info = mySociety::MaPit::get_voting_area_info(uc $q_council);
+ my $va_info = mySociety::MaPit::call('area/ons', uc $q_council);
$area_name = Page::short_name($va_info->{name});
if (length($q_council) == 6) {
- $va_info = mySociety::MaPit::get_voting_area_info($va_info->{parent_area_id});
+ $va_info = mySociety::MaPit::call('area', $va_info->{parent_area});
$area_name = Page::short_name($va_info->{name}) . '/' . $area_name;
}
$rss = '/rss' if $rss;
print $q->redirect($base_url . $rss . '/reports/' . $area_name);
return;
} elsif ($q_council =~ /\D/) {
- (my $qc = $q_council) =~ s/ and / & /;
- my $areas = mySociety::MaPit::get_voting_area_by_name($qc, $mySociety::VotingArea::council_parent_types, 10);
+ my $areas = mySociety::MaPit::call('areas', $q_council, type => $mySociety::VotingArea::council_parent_types, min_generation=>10 );
if (keys %$areas == 1) {
($one_council) = keys %$areas;
$area_type = $areas->{$one_council}->{type};
$area_name = $areas->{$one_council}->{name};
} else {
foreach (keys %$areas) {
- if ($areas->{$_}->{name} =~ /^\Q$qc\E (Borough|City|District|County) Council$/) {
+ if ($areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/) {
$one_council = $_;
$area_type = $areas->{$_}->{type};
- $area_name = $qc;
+ $area_name = $q_council;
}
}
}
@@ -63,7 +62,7 @@ sub main {
return;
}
} elsif ($q_council =~ /^\d+$/) {
- my $va_info = mySociety::MaPit::get_voting_area_info($q_council);
+ my $va_info = mySociety::MaPit::call('area', $q_council);
$area_name = $va_info->{name};
print $q->redirect($base_url . '/reports/' . Page::short_name($area_name));
return;
@@ -74,9 +73,9 @@ sub main {
my $q_ward = $q->param('ward') || '';
my $ward;
if ($one_council && $q_ward) {
- my $qw = mySociety::MaPit::get_voting_area_by_name($q_ward, $mySociety::VotingArea::council_child_types, 10);
+ my $qw = mySociety::MaPit::call('areas', $q_ward, type => $mySociety::VotingArea::council_child_types, min_generation => 10);
foreach my $id (sort keys %$qw) {
- if ($qw->{$id}->{parent_area_id} == $one_council) {
+ if ($qw->{$id}->{parent_area} == $one_council) {
$ward = $id;
last;
}
@@ -116,21 +115,21 @@ sub main {
return;
}
- my %councils;
+ my $areas_info;
if ($one_council) {
- %councils = ( $one_council => 1 );
+ $areas_info = mySociety::MaPit::call('areas', $one_council);
} else {
# Show all councils on main report page
my $ignore = 'LGD';
$ignore .= '|CTY' if $q->{site} eq 'emptyhomes';
my @types = grep { !/$ignore/ } @$mySociety::VotingArea::council_parent_types;
- %councils = map { $_ => 1 } @{mySociety::MaPit::get_areas_by_type(\@types, 10)};
+ $areas_info = mySociety::MaPit::call('areas', [ @types ], min_generation=>10 );
}
my $problems = Problems::council_problems($ward, $one_council);
my (%fixed, %open);
- my $re_councils = join('|', keys %councils);
+ my $re_councils = join('|', keys %$areas_info);
foreach my $row (@$problems) {
if (!$row->{council}) {
# Problem was not sent to any council, add to possible councils
@@ -148,7 +147,6 @@ sub main {
}
}
- my $areas_info = mySociety::MaPit::get_voting_areas_info([keys %councils]);
if (!$one_council) {
print Page::header($q, title=>_('Summary reports'), expires=>'+1h');
print $q->p(
@@ -162,7 +160,7 @@ sub main {
print '<th>' . _('Old problems,<br>state unknown') . '</th>';
}
print '<th>' . _('Recently fixed') . '</th><th>' . _('Older fixed') . '</th></tr>';
- foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) {
+ foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %$areas_info) {
print '<tr align="center"';
++$c;
if ($areas_info->{$_}->{generation_high}==10) {
diff --git a/web/rss.cgi b/web/rss.cgi
index a2810aee8..7060d1709 100755
--- a/web/rss.cgi
+++ b/web/rss.cgi
@@ -43,7 +43,7 @@ sub main {
$out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand. $q);
} elsif ($type eq 'area_problems') {
my $id = $q->param('id');
- my $va_info = mySociety::MaPit::get_voting_area_info($id);
+ my $va_info = mySociety::MaPit::call('area', $id);
my $qs = '/'.$id;
$out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], { NAME => $va_info->{name} }, $cobrand, $q);
} elsif ($type eq 'all_problems') {