aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/make_css18
-rwxr-xr-xbin/send-reports40
2 files changed, 54 insertions, 4 deletions
diff --git a/bin/make_css b/bin/make_css
new file mode 100755
index 000000000..7e01da267
--- /dev/null
+++ b/bin/make_css
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# make_css:
+# Generate CSS files from SCSS files.
+# Curerntly the CSS files are also in version control, though I guess
+# in future they don't need to be, and compressed style could then be used.
+#
+# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
+#
+# $Id: send-reports,v 1.79 2010-01-06 16:50:26 louise Exp $
+
+DIRECTORY=$(cd `dirname $0` && pwd)
+
+for file in `find $DIRECTORY/../ -name "*.scss" ! -name "_*"`; do
+ sass --style expanded $file ${file/scss/css}
+done
+
diff --git a/bin/send-reports b/bin/send-reports
index 84bfb1791..8e6d2d178 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -18,6 +18,8 @@ use lib "$FindBin::Bin/../commonlib/perllib";
use Encode;
use Error qw(:try);
use File::Slurp;
+use JSON;
+use LWP::Simple;
use CGI; # Trying awkward kludge
use CronFns;
@@ -97,9 +99,8 @@ foreach my $row (@$unsent) {
$h{fuzzy} = $row->{used_map} ? _('To view a map of the precise location of this issue')
: _('The user could not locate the problem on a map, but to see the area around the location they entered');
$h{closest_address} = '';
- $h{closest_address_machine} = '';
- # If we are in the UK include eastings and northings
+ # If we are in the UK include eastings and northings, and nearest stuff
$h{easting_northing} = '';
if ( mySociety::Config::get('COUNTRY') eq 'GB' ) {
@@ -109,7 +110,10 @@ foreach my $row (@$unsent) {
$h{easting_northing} #
= "Easting: $h{easting}\n\n" #
. "Northing: $h{northing}\n\n";
+
+ $h{closest_address} = find_closest($row, $h{latitude}, $h{longitude});
}
+ $h{closest_address_machine} = $h{closest_address};
my (@to, @recips, $template, $areas_info);
if ($site eq 'emptyhomes') {
@@ -138,7 +142,7 @@ foreach my $row (@$unsent) {
# XXX Needs locks!
my @all_councils = split /,|\|/, $row->{council};
my ($councils, $missing) = $row->{council} =~ /^([\d,]+)(?:\|([\d,]+))?/;
- my @councils = split /,/, $councils;
+ my @councils = split(/,/, $councils);
$areas_info = mySociety::MaPit::call('areas', \@all_councils);
my (@dear, %recips);
my $all_confirmed = 1;
@@ -174,7 +178,7 @@ foreach my $row (@$unsent) {
$template = 'submit-brent' if $row->{council} eq 2488 || $row->{council} eq 2237;
$template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/$template");
- if ($h{category} eq 'Other') {
+ if ($h{category} eq _('Other')) {
$h{category_footer} = _('this type of local problem');
$h{category_line} = '';
} else {
@@ -342,3 +346,31 @@ sub post_easthants_message {
return $return;
}
+sub find_closest {
+ my ($row, $latitude, $longitude) = @_;
+ my $str = '';
+
+ return '' unless $row->{used_map};
+
+ # Get nearest road-type thing from Bing
+ my $url = "http://dev.virtualearth.net/REST/v1/Locations/$latitude,$longitude?c=en-GB&key=" . mySociety::Config::get('BING_MAPS_API_KEY');
+ my $j = LWP::Simple::get($url);
+ if ($j) {
+ $j = JSON->new->utf8->allow_nonref->decode($j);
+ if ($j->{resourceSets}[0]{resources}[0]{name}) {
+ $str .= "Nearest road to the pin placed on the map (automatically generated by Bing Maps): $j->{resourceSets}[0]{resources}[0]{name}\n\n";
+ }
+ }
+
+ # Get nearest postcode from Matthew's random gazetteer (put in MaPit? Or elsewhere?)
+ $url = "http://gazetteer.dracos.vm.bytemark.co.uk/point/$latitude,$longitude.json";
+ $j = LWP::Simple::get($url);
+ if ($j) {
+ $j = JSON->new->utf8->allow_nonref->decode($j);
+ if ($j->{postcode}) {
+ $str .= "Nearest postcode to the pin placed on the map (automatically generated): $j->{postcode}[0] ($j->{postcode}[1]m away)\n\n";
+ }
+ }
+ return $str;
+}
+