diff options
author | matthew <matthew> | 2007-05-09 20:07:00 +0000 |
---|---|---|
committer | matthew <matthew> | 2007-05-09 20:07:00 +0000 |
commit | 1434cfbaf58d6d4f8d1d8b838e32d88ad99e85ec (patch) | |
tree | 447e98dbc8aa3216f115616fc910b3b9d635d203 | |
parent | e0bb98af712922e563b80cbe1bfcf8d3d49a022d (diff) |
Use canonical councils everywhere.
-rw-r--r-- | perllib/Page.pm | 22 | ||||
-rwxr-xr-x | web-admin/index.cgi | 18 | ||||
-rwxr-xr-x | web/index.cgi | 10 | ||||
-rwxr-xr-x | web/report.cgi | 11 |
4 files changed, 31 insertions, 30 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index 4e7a17ed7..0986328a9 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.pm,v 1.44 2007-05-09 13:31:07 matthew Exp $ +# $Id: Page.pm,v 1.45 2007-05-09 20:07:00 matthew Exp $ # package Page; @@ -199,7 +199,7 @@ $params{pre} $params{post} </div> EOF - $out .= Page::compass($q, $x, $y); + $out .= compass($q, $x, $y); $out .= '<div id="side">'; return $out; } @@ -369,15 +369,15 @@ sub display_problem_text { # Display information about problem $out .= '<p><em>Reported '; $out .= ($problem->{anonymous}) ? 'anonymously' : "by " . ent($problem->{name}); - $out .= ' at ' . Page::prettify_epoch($problem->{time}); + $out .= ' at ' . prettify_epoch($problem->{time}); if ($problem->{council}) { if ($problem->{whensent}) { $problem->{council} =~ s/\|.*//g; my @councils = split /,/, $problem->{council}; my $areas_info = mySociety::MaPit::get_voting_areas_info(\@councils); - my $council = join(' and ', map { $areas_info->{$_}->{name} } @councils); + my $council = join(' and ', map { canonicalise_council($areas_info->{$_}->{name}) } @councils); $out .= $q->br() . $q->small('Sent to ' . $council . ' ' . - Page::prettify_duration($problem->{whensent}, 'minute') . ' later'); + prettify_duration($problem->{whensent}, 'minute') . ' later'); } } else { $out .= $q->br() . $q->small('Not reported to council'); @@ -411,7 +411,7 @@ sub display_problem_updates { } else { $out .= "Posted anonymously"; } - $out .= " at " . Page::prettify_epoch($row->{created}); + $out .= " at " . prettify_epoch($row->{created}); $out .= ', marked fixed' if ($row->{mark_fixed}); $out .= ', reopened' if ($row->{mark_open}); $out .= '</em>'; @@ -422,4 +422,14 @@ sub display_problem_updates { return $out; } +sub canonicalise_council { + my $c = shift; + $c =~ s/City of //; + $c =~ s/N\. /North /; + $c =~ s/E\. /East /; + $c =~ s/W\. /West /; + $c =~ s/S\. /South /; + return $c; +} + 1; diff --git a/web-admin/index.cgi b/web-admin/index.cgi index a37b93ec6..4dc0963c1 100755 --- a/web-admin/index.cgi +++ b/web-admin/index.cgi @@ -7,10 +7,10 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: index.cgi,v 1.39 2007-05-09 11:39:44 matthew Exp $ +# $Id: index.cgi,v 1.40 2007-05-09 20:07:01 matthew Exp $ # -my $rcsid = ''; $rcsid .= '$Id: index.cgi,v 1.39 2007-05-09 11:39:44 matthew Exp $'; +my $rcsid = ''; $rcsid .= '$Id: index.cgi,v 1.40 2007-05-09 20:07:01 matthew Exp $'; use strict; @@ -147,16 +147,6 @@ sub do_summary ($) { print html_tail($q); } -sub canonicalise_council { - my $c = shift; - $c =~ s/City of //; - $c =~ s/N\. /North /; - $c =~ s/E\. /East /; - $c =~ s/W\. /West /; - $c =~ s/S\. /South /; - return $c; -} - # do_councils_list CGI sub do_councils_list ($) { my ($q) = @_; @@ -181,7 +171,7 @@ sub do_councils_list ($) { } my $councils = mySociety::MaPit::get_voting_areas_info(\@councils); my @councils_ids = keys %$councils; - @councils_ids = sort { canonicalise_council($councils->{$a}->{name}) cmp canonicalise_council($councils->{$b}->{name}) } @councils_ids; + @councils_ids = sort { Page::canonicalise_council($councils->{$a}->{name}) cmp Page::canonicalise_council($councils->{$b}->{name}) } @councils_ids; my $bci_info = dbh()->selectall_hashref(" select area_id, count(*) as c, count(case when deleted then 1 else null end) as deleted, count(case when confirmed then 1 else null end) as confirmed @@ -193,7 +183,7 @@ sub do_councils_list ($) { map { $q->a({href=>build_url($q, $q->url('relative'=>1), {'area_id' => $_, 'page' => 'councilcontacts',})}, - canonicalise_council($councils->{$_}->{name})) . " " . + Page::canonicalise_council($councils->{$_}->{name})) . " " . ($bci_info->{$_} ? $bci_info->{$_}->{c} . ' addresses' : '') diff --git a/web/index.cgi b/web/index.cgi index 64780eb40..083bd5644 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.126 2007-05-09 16:16:59 matthew Exp $ +# $Id: index.cgi,v 1.127 2007-05-09 20:07:01 matthew Exp $ use strict; require 5.8.0; @@ -367,7 +367,7 @@ EOF if ($details eq 'all') { $out .= '<p>All the details you provide here will be sent to <strong>' - . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils) + . join('</strong> or <strong>', map { Page::canonicalise_council($areas_info->{$_}->{name}) } @$all_councils) . '</strong>. We show the subject and details of the problem on the site, along with your name if you give us permission.</p>'; $out .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">'; @@ -379,9 +379,9 @@ EOF push @missing, $_ unless $councils{$_}; } my $n = @missing; - my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing); + my $list = join(' or ', map { Page::canonicalise_council($areas_info->{$_}->{name}) } @missing); $out .= '<p>All the details you provide here will be sent to <strong>' - . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils) + . join('</strong> or <strong>', map { Page::canonicalise_council($areas_info->{$_}->{name}) } @councils) . '</strong>. We show the subject and details of the problem on the site, along with your name if you give us permission.</p>'; $out .= ' We do <strong>not</strong> yet have details for the other council'; @@ -392,7 +392,7 @@ problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>.</p>"; . '|' . join(',', @missing) . '">'; } else { my $e = mySociety::Config::get('CONTACT_EMAIL'); - my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils); + my $list = join(' or ', map { Page::canonicalise_council($areas_info->{$_}->{name}) } @$all_councils); my $n = @$all_councils; $out .= '<p>We do not yet have details for the council'; $out .= ($n>1) ? 's that cover' : ' that covers'; diff --git a/web/report.cgi b/web/report.cgi index 39f3a621e..8321a4935 100755 --- a/web/report.cgi +++ b/web/report.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: report.cgi,v 1.19 2007-05-09 19:59:04 matthew Exp $ +# $Id: report.cgi,v 1.20 2007-05-09 20:07:01 matthew Exp $ use strict; require 5.8.0; @@ -78,8 +78,9 @@ sub main { print '<table>'; print '<tr><th>Name</th><th>New problems</th><th>Old problems, still present</th> <th>Old problems, state unknown</th><th>Recently fixed</th><th>Old fixed</th></tr>'; - foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) { - print '<tr><td><a href="report?council=' . $_ . '">' . $areas_info->{$_}->{name} . '</a></td>'; + foreach (sort { Page::canonicalise_council($areas_info->{$a}->{name}) cmp Page::canonicalise_council($areas_info->{$b}->{name}) } keys %councils) { + print '<tr><td><a href="report?council=' . $_ . '">' . + Page::canonicalise_council($areas_info->{$_}->{name}) . '</a></td>'; summary_cell(\@{$open{$_}{new}{new}}); summary_cell(\@{$open{$_}{old}{new}}); summary_cell(\@{$open{$_}{old}{old}}); @@ -94,8 +95,8 @@ sub main { ' or go back and ' . $q->a({href => NewURL($q, all=>undef, council=>undef) }, 'show all councils') . '.'); - foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) { - print '<h2>' . $areas_info->{$_}->{name} . "</h2>\n"; + foreach (sort { Page::canonicalise_council($areas_info->{$a}->{name}) cmp Page::canonicalise_council($areas_info->{$b}->{name}) } keys %councils) { + print '<h2>' . Page::canonicalise_council($areas_info->{$_}->{name}) . "</h2>\n"; list_problems('New problems', $open{$_}{new}{new}, $all) if $open{$_}{new}{new}; list_problems('Old problems, still present', $open{$_}{old}{new}, $all) if $open{$_}{old}{new}; list_problems('Old problems, state unknown', $open{$_}{old}{old}, $all) if $open{$_}{old}{old}; |