diff options
-rwxr-xr-x | web/reports.cgi | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/web/reports.cgi b/web/reports.cgi index f4823739c..5dcc5c438 100755 --- a/web/reports.cgi +++ b/web/reports.cgi @@ -7,7 +7,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: reports.cgi,v 1.11 2007-08-29 23:03:16 matthew Exp $ +# $Id: reports.cgi,v 1.12 2007-08-31 10:19:36 matthew Exp $ use strict; use Standard; @@ -28,11 +28,19 @@ sub main { my ($one_council, $area_type, $area_name); if ($q_council =~ /\D/) { (my $qc = $q_council) =~ s/ and / & /; - $qc = mySociety::MaPit::get_voting_area_by_name("$qc ", $mySociety::VotingArea::council_parent_types); - if (keys %$qc == 1) { - ($one_council) = keys %$qc; - $area_type = $qc->{$one_council}->{type}; - $area_name = $qc->{$one_council}->{name}; + my $areas = mySociety::MaPit::get_voting_area_by_name($qc, $mySociety::VotingArea::council_parent_types); + 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$/) { + $one_council = $_; + $area_type = $areas->{$_}->{type}; + $area_name = $qc; + } + } } if (!$one_council) { # Given a false council name print $q->redirect('/reports'); |