aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gettext-extract4
-rwxr-xr-xbin/import-flickr17
-rwxr-xr-xbin/send-questionnaires3
-rwxr-xr-xbin/send-reports23
-rwxr-xr-xbin/test-run17
5 files changed, 27 insertions, 37 deletions
diff --git a/bin/gettext-extract b/bin/gettext-extract
index b354c11f2..24defd014 100755
--- a/bin/gettext-extract
+++ b/bin/gettext-extract
@@ -40,7 +40,7 @@ PO=locale/FixMyStreet.po
rm -f $PO
# Extract from Perl
-xgettext --add-comments=TRANS --language=Perl --keyword=_ --keyword=nget:1,2 --from-code=utf-8 -o $PO perllib/*.pm perllib/FixMyStreet/*.pm web/*.cgi bin/send-* db/alert_types_eha.pl
+xgettext --add-comments=TRANS --language=Perl --keyword=_ --keyword=nget:1,2 --from-code=utf-8 -o $PO `find perllib -name "*.pm"` web/*.cgi bin/send-* db/*.pl web-admin/*.cgi
# Fix headers
TEMP=`tempfile`
@@ -76,5 +76,5 @@ do
fi
done
-fixmystreet/bin/make_emptyhomes_po
+bin/make_emptyhomes_po
diff --git a/bin/import-flickr b/bin/import-flickr
index 21ea5822a..f4a838547 100755
--- a/bin/import-flickr
+++ b/bin/import-flickr
@@ -24,7 +24,6 @@ use mySociety::Config;
use mySociety::DBHandle qw(dbh select_all);
use mySociety::EmailUtil;
use mySociety::Email;
-use mySociety::GeoUtil;
BEGIN {
mySociety::Config::set_file("$FindBin::Bin/../conf/general");
@@ -55,28 +54,28 @@ foreach (@$st) {
# XXX: Hmm... Use format=perl now Cal has added it for me! :)
while ($result =~ /<photo id="([^"]*)" owner="([^"]*)" secret="([^"]*)" server="([^"]*)" farm="([^"]*)" title="([^"]*)".*?latitude="([^"]*)" longitude="([^"]*)".*?machine_tags="([^"]*)"/g) {
- my ($id, $owner, $secret, $server, $farm, $title, $lat, $lon, $machine) = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
+ my ($id, $owner, $secret, $server, $farm, $title, $latitude, $longitude, $machine) = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
next if $ids{$id};
- if ($machine =~ /geo:/ && !$lat && !$lon) {
+ if ($machine =~ /geo:/ && !$latitude && !$longitude) {
# Have to fetch raw tags, as otherwise can't tell if it's negative, or how many decimal places
my $url = 'http://api.flickr.com/services/rest/?method=flickr.tags.getListPhoto&api_key=' . $key . '&photo_id=' . $id;
my $tags = get($url);
- ($lon) = $tags =~ /raw="geo:lon=([^"]*)"/i;
- ($lat) = $tags =~ /raw="geo:lat=([^"]*)"/i;
+ ($longitude) = $tags =~ /raw="geo:lon=([^"]*)"/i;
+ ($latitude) = $tags =~ /raw="geo:lat=([^"]*)"/i;
}
my $url = "http://farm$farm.static.flickr.com/$server/".$id.'_'.$secret.'_m.jpg';
my $image = get($url);
- problem_create($id, $owner, $title, $lat, $lon, $image);
+ problem_create($id, $owner, $title, $latitude, $longitude, $image);
}
sub problem_create {
- my ($photo_id, $owner, $title, $lat, $lon, $image) = @_;
+ my ($photo_id, $owner, $title, $latitude, $longitude, $image) = @_;
my ($name, $email) = dbh()->selectrow_array("select name, email from partial_user where service='flickr' and nsid=?", {}, $owner);
# set some defaults
$name ||= '';
- $lat ||= 0;
- $lon ||= 0;
+ $latitude ||= 0;
+ $longitude ||= 0;
my $id = dbh()->selectrow_array("select nextval('problem_id_seq')");
Utils::workaround_pg_bytea("insert into problem
diff --git a/bin/send-questionnaires b/bin/send-questionnaires
index eb67cd5d1..d3945bf12 100755
--- a/bin/send-questionnaires
+++ b/bin/send-questionnaires
@@ -17,6 +17,7 @@ use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../commonlib/perllib";
use File::Slurp;
use CGI; # XXX Awkward kludge
+use Encode;
use CronFns;
use Page;
@@ -62,7 +63,7 @@ foreach my $row (@$unsent) {
my @all_councils = split /,|\|/, $row->{council};
my $cobrand = $row->{cobrand};
my $lang = $row->{lang};
- Cobrand::set_lang_and_domain($cobrand, $lang);
+ Cobrand::set_lang_and_domain($cobrand, $lang, 1);
# Cobranded and non-cobranded messages can share a database. In this case, the conf file
# should specify a vhost to send the reports for each cobrand, so that they don't get sent
# more than once if there are multiple vhosts running off the same database. The email_host
diff --git a/bin/send-reports b/bin/send-reports
index 6254337c6..84bfb1791 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -23,11 +23,11 @@ use CronFns;
use EastHantsWSDL;
use Cobrand;
+use Utils;
use mySociety::Config;
use mySociety::DBHandle qw(dbh);
use mySociety::Email;
use mySociety::EmailUtil;
-use mySociety::GeoUtil;
use mySociety::Locale;
use mySociety::MaPit;
use mySociety::Random qw(random_bytes);
@@ -70,7 +70,7 @@ foreach my $row (@$unsent) {
# more than once if there are multiple vhosts running off the same database. The email_host
# call checks if this is the host that sends mail for this cobrand.
next unless (Cobrand::email_host($cobrand));
- Cobrand::set_lang_and_domain($cobrand, $row->{lang});
+ Cobrand::set_lang_and_domain($cobrand, $row->{lang}, 1);
if (dbh()->selectrow_array('select email from abuse where lower(email)=?', {}, lc($row->{email}))) {
dbh()->do("update problem set state='hidden' where id=?", {}, $row->{id});
dbh()->commit();
@@ -103,10 +103,7 @@ foreach my $row (@$unsent) {
$h{easting_northing} = '';
if ( mySociety::Config::get('COUNTRY') eq 'GB' ) {
- ( $h{easting}, $h{northing} ) =
- mySociety::GeoUtil::wgs84_to_national_grid( #
- $h{latitude}, $h{longitude}, 'G'
- );
+ ( $h{easting}, $h{northing} ) = Utils::convert_latlon_to_en( $h{latitude}, $h{longitude} );
# email templates don't have conditionals so we need to farmat this here
$h{easting_northing} #
@@ -178,22 +175,22 @@ foreach my $row (@$unsent) {
$template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/$template");
if ($h{category} eq 'Other') {
- $h{category_footer} = 'this type of local problem';
+ $h{category_footer} = _('this type of local problem');
$h{category_line} = '';
} else {
$h{category_footer} = "'" . $h{category} . "'";
- $h{category_line} = "Category: $h{category}\n\n";
+ $h{category_line} = sprintf(_("Category: %s"), $h{category}) . "\n\n";
}
- $h{councils_name} = join(' and ', @dear);
- $h{multiple} = @dear>1 ? "[ This email has been sent to both councils covering the location of the problem, as the user did not categorise it; please ignore it if you're not the correct council to deal with the issue, or let us know what category of problem this is so we can add it to our system. ]\n\n"
+ $h{councils_name} = join(_(' and '), @dear);
+ $h{multiple} = @dear>1 ? "[ " . _("This email has been sent to both councils covering the location of the problem, as the user did not categorise it; please ignore it if you're not the correct council to deal with the issue, or let us know what category of problem this is so we can add it to our system.") . " ]\n\n"
: '';
$h{missing} = '';
if ($missing) {
my $name = $areas_info->{$missing}->{name};
- $h{missing} = '[ We realise this problem might be the responsibility of ' . $name
- . "; however, we don't currently have any contact details for them.
-If you know of an appropriate contact address, please do get in touch. ]\n\n";
+ $h{missing} = '[ '
+ . sprintf(_('We realise this problem might be the responsibility of %s; however, we don\'t currently have any contact details for them. If you know of an appropriate contact address, please do get in touch.'), $name)
+ . " ]\n\n";
}
}
diff --git a/bin/test-run b/bin/test-run
index b2fea2fb5..9c3142207 100755
--- a/bin/test-run
+++ b/bin/test-run
@@ -27,7 +27,6 @@ use FindBin;
use mySociety::Config;
mySociety::Config::set_file('../conf/general');
use mySociety::DBHandle qw(dbh);
-use mySociety::GeoUtil;
use mySociety::WebTestHarness;
use Test::Harness;
use File::Find;
@@ -392,10 +391,7 @@ sub do_alert {
my $e = 325066;
my $n = 673533;
- # get the lat,lon from the postcode so that it matches
- my ( $lat, $lon ) =
- map { Utils::truncate_coordinate($_) }
- FixMyStreet::Geocode::lookup( $postcode, undef );
+ my ( $lat, $lon ) = (55.948967, -3.201478);
my $messages = english_fms_messages();
submit_postcode('', $postcode, 'Problems in this area');
@@ -438,10 +434,7 @@ sub do_eha_alert {
my $x = 2015; my $e = 325066;
my $y = 4175; my $n = 673533;
- # get the lat,lon from the postcode so that it matches
- my ( $lat, $lon ) =
- map { Utils::truncate_coordinate($_) }
- FixMyStreet::Geocode::lookup( $postcode, undef );
+ my ( $lat, $lon ) = (55.948967, -3.201478);
my @texts = ('Eiddo gwag yn yr ardal hon',
'Adrodd am eiddo gwag',
@@ -540,15 +533,15 @@ sub do_rss {
my %redirects = (
- # should always go to lat lon
+ # should always go to lat lon, except postcode (actually, query string)
'/rss/n/406886,289126' => '/rss/l/52.499994,-1.899993',
'/rss/2524/1779' => '/rss/l/52.480294,-1.896931',
- '/rss/pc/SW1A1AA' => '/rss/l/51.50101,-0.141587',
+ '/rss/pc/SW1A1AA' => '/rss/pc/SW1A1AA',
'/rss/l/52.5/-1.9' => '/rss/l/52.5/-1.9',
# go to reports
'/rss/area/Birmingham' => '/rss/reports/Birmingham',
- '/rss/area/Birmingham/Lozells' => '/rss/reports/Birmingham/Lozells',
+ '/rss/area/Birmingham/Lozells' => '/rss/reports/Birmingham/Lozells+and+East+Handsworth',
);
my $error_count = 0;