aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2007-02-06 10:32:04 +0000
committermatthew <matthew>2007-02-06 10:32:04 +0000
commit0a96ab4ce58fcc6889ea32b9c74218f5a01aeb6c (patch)
treecdb65ed0317b6e7a6abafbe34dd9b9bd94f59da2
parenta9906c986979e448508e169e379fd00eecdde223 (diff)
Tabs, text tweaks.
-rwxr-xr-xbin/send-reports20
-rwxr-xr-xweb/index.cgi25
2 files changed, 26 insertions, 19 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 0be6d3db8..638c55c33 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: send-reports,v 1.9 2007-02-06 09:42:44 matthew Exp $
+# $Id: send-reports,v 1.10 2007-02-06 10:32:04 matthew Exp $
use strict;
require 5.8.0;
@@ -39,21 +39,27 @@ my $nomail = 0;
$nomail = 1 if (@ARGV==1 && $ARGV[0] eq '--nomail');
my $unsent = dbh()->selectall_arrayref(
- "SELECT id, council, title, detail, created, name, email, phone, used_map
+ "SELECT id, council, title, detail, name, email, phone, used_map
FROM problem WHERE state = 'confirmed' AND whensent IS NULL", { Slice => {} });
foreach my $row (@$unsent) {
# XXX Needs locks!
my @councils = split ',', $row->{council};
my $areas_info = mySociety::MaPit::get_voting_areas_info(\@councils);
- my @to;
- my @recips = (mySociety::Config::get('CONTACT_EMAIL'));
+ my (@to, @recips);
foreach my $council (@councils) {
+ my $name = $areas_info->{$council}->{name};
my $council_email = dbh()->selectrow_array('SELECT email FROM contacts WHERE area_id=?', {}, $council);
- throw Error::Simple('Missing email!') unless $council_email;
- push @to, [ $council_email, $areas_info->{$council}->{name} ];
+ next unless $council_email; # Ignore missing councils
+ push @to, [ $council_email, $name ];
push @recips, $council_email;
}
print 'Need to send problem #' . $row->{id} . ' to council(s) ' . join(',',@recips) . "\n";
+ if (!@to) {
+ print " ...but we have no contact details for any of them!\n";
+ next;
+ }
+
+ push @recips, mySociety::Config::get('CONTACT_EMAIL');
my $template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/submit-council");
my %h = map { $_ => $row->{$_} } qw/title detail/;
@@ -68,7 +74,7 @@ foreach my $row (@$unsent) {
_parameters_ => \%h,
From => [ mySociety::Config::get('CONTACT_EMAIL'), mySociety::Config::get('CONTACT_NAME') ],
To => \@to,
- 'Reply-To' => [ [ $row->{email}, $row->{name} ] ]
+ 'Reply-To' => [ [ $row->{email}, $row->{name} ] ]
});
my $result;
diff --git a/web/index.cgi b/web/index.cgi
index c0eeacd80..39047712b 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.67 2007-02-02 23:24:01 matthew Exp $
+# $Id: index.cgi,v 1.68 2007-02-06 10:32:04 matthew Exp $
# TODO
# Nothing is done about the update checkboxes - not stored anywhere on anything!
@@ -176,20 +176,21 @@ sub submit_problem {
if ($input{council} ne '-1') {
my $councils = mySociety::MaPit::get_voting_area_by_location_en($input{easting}, $input{northing}, 'polygon', $mySociety::VotingArea::council_parent_types);
my %councils = map { $_ => 1 } @$councils;
- my @input_councils = split /,/, $input{council};
- foreach (@input_councils) {
+ my @input_councils = split /,/, $input{council};
+ foreach (@input_councils) {
if (!$councils{$_}) {
push(@errors, 'That location is not part of that council');
- last;
- }
- }
- my @valid_councils = is_valid_council(\@input_councils);
+ last;
+ }
+ }
+ my @valid_councils = is_valid_council(\@input_councils);
push(@errors, 'We do not yet have details for the council that covers that location') unless @valid_councils;
- $input{council} = join(',', @valid_councils);
-
+ $input{council} = join(',', @valid_councils);
}
} elsif ($input{easting} || $input{northing}) {
push(@errors, 'Somehow, you only have one co-ordinate. Please try again.');
+ } else {
+ push(@errors, 'You haven\'t specified any sort of co-ordinates. Please try again.');
}
return display_form($q, @errors) if (@errors);
@@ -213,7 +214,7 @@ sub submit_problem {
# This is horrid
my $s = dbh()->prepare("insert into problem
(id, postcode, easting, northing, title, detail, name,
- email, phone, photo, state, council, used_map)
+ email, phone, photo, state, council, used_map)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'unconfirmed', ?, ?)");
$s->bind_param(1, $id);
@@ -301,12 +302,12 @@ EOF
}
if (@councils > 0) {
$out .= '<p>This problem will be reported to <strong>'
- . join('</strong> and <strong>', map { $areas_info->{$_}->{name} } @councils)
+ . join('</strong> and <strong>', map { $areas_info->{$_}->{name} } @councils)
. '</strong>.</p>';
$out .= '<input type="hidden" name="council" value="' . join(',',@councils) . '">';
} else {
my $e = mySociety::Config::get('CONTACT_EMAIL');
- my $list = join(', ', map { $areas_info->{$_}->{name} } @$all_councils);
+ my $list = join(' and ', map { $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';