diff options
author | Marius Halden <marius.h@lden.org> | 2017-05-28 21:31:42 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2017-05-28 21:31:42 +0200 |
commit | 987124b09a32248414faf4d0d6615d43b29ac6f6 (patch) | |
tree | a549db8af723c981d3b346e855f25d6fd5ff8aa7 /bin | |
parent | dbf56159e44c1560a413022451bf1a1c4cb22a52 (diff) | |
parent | a085b63ce09f87e83b75cda9b9cd08aadfe75d61 (diff) |
Merge tag 'v2.0.4' into fiksgatami-dev
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/generate_cobrand_po | 14 | ||||
-rwxr-xr-x | bin/gettext-nget-patch | 10 | ||||
-rwxr-xr-x | bin/handlemail | 9 | ||||
-rwxr-xr-x | bin/open311-populate-service-list | 3 | ||||
-rwxr-xr-x | bin/oxfordshire/archive-old-enquiries | 29 | ||||
-rwxr-xr-x | bin/oxfordshire/open311_service_request_update.cgi | 2 | ||||
-rw-r--r-- | bin/oxfordshire/open311_services.pm | 16 | ||||
-rw-r--r-- | bin/site-specific-install.sh | 2 | ||||
-rwxr-xr-x | bin/update-schema | 3 |
9 files changed, 72 insertions, 16 deletions
diff --git a/bin/generate_cobrand_po b/bin/generate_cobrand_po index 1770de7c2..8e62230ae 100755 --- a/bin/generate_cobrand_po +++ b/bin/generate_cobrand_po @@ -13,14 +13,22 @@ the main FixMyStreet po files =cut -my $cobrand = shift; +use File::Basename qw(dirname); +use File::Spec; +my $cobrand = shift; die "Please provide a cobrand name\n" unless $cobrand; -my $cobrand_lc = lc( $cobrand ); +my $d = dirname(dirname(File::Spec->rel2abs($0))); +chdir $d; -my $PO = "locale/$cobrand.po"; +# Install required code if needed +system("vendor/bin/carton install --path local-gettext --cpanfile locale/cpanfile --deployment"); +$ENV{PATH} = "local-gettext/bin:$ENV{PATH}"; +$ENV{PERL5LIB} = "local-gettext/lib/perl5:local/lib/perl5"; +my $cobrand_lc = lc( $cobrand ); +my $PO = "locale/$cobrand.po"; my $cobrand_module = "perllib/FixMyStreet/Cobrand/$cobrand.pm"; my $web_templates = "templates/web/$cobrand_lc/"; diff --git a/bin/gettext-nget-patch b/bin/gettext-nget-patch index 92b687552..67f98e319 100755 --- a/bin/gettext-nget-patch +++ b/bin/gettext-nget-patch @@ -18,19 +18,19 @@ find( sub { do { $text .= <FP>; } until $text =~ /\)/; - if ($text =~ /nget\(\s*"(.*?)"\s*,\s*"(.*?)"\s*,\s*(.*?)\s*\)/s) { - $out{$1} = { + if ($text =~ /nget\(\s*(['"])(.*?)\1\s*,\s*(['"])(.*?)\3\s*,\s*(.*?)\s*\)/s) { + $out{$2} = { file => $File::Find::name, line => $line, - s => $1, - p => $2, + s => $2, + p => $4, }; } } close FP; }, 'templates', 'perllib'); -foreach (values %out) { +foreach (sort { $a->{s} cmp $b->{s} } values %out) { print <<EOF; #: $_->{file}:$_->{line} diff --git a/bin/handlemail b/bin/handlemail index cc671f786..e027b8f58 100755 --- a/bin/handlemail +++ b/bin/handlemail @@ -172,20 +172,19 @@ sub handle_non_bounce_to_null_address { To => $data{return_path}, _body_ => $template, }); - send_mail($mail->as_string, '<>', $data{return_path}); + send_mail($mail->as_string, $data{return_path}); } sub forward_on_to { my $recipient = shift; my $text = join("\n", @lines) . "\n"; - my $sender = $data{return_path} || '<>'; - send_mail($text, $sender, $recipient); + send_mail($text, $recipient); } sub send_mail { - my ($text, $sender, $recipient) = @_; + my ($text, $recipient) = @_; if (mySociety::EmailUtil::EMAIL_SUCCESS - != mySociety::EmailUtil::send_email($text, $sender, $recipient)) { + != mySociety::EmailUtil::send_email($text, '<>', $recipient)) { exit(75); } } diff --git a/bin/open311-populate-service-list b/bin/open311-populate-service-list index 211061258..8cb41a47b 100755 --- a/bin/open311-populate-service-list +++ b/bin/open311-populate-service-list @@ -23,7 +23,8 @@ my ($opt, $usage) = describe_options( print($usage->text), exit if $opt->help; my $bodies = FixMyStreet::DB->resultset('Body')->search( { - id => { '!=', 2237 }, # XXX Until Oxfordshire does do so + # Until Oxfordshire does, and Bristol stops erroring + name => { -not_in => [ 'Oxfordshire County Council', 'Bristol City Council' ] }, send_method => 'Open311' } ); my $verbose = 0; diff --git a/bin/oxfordshire/archive-old-enquiries b/bin/oxfordshire/archive-old-enquiries new file mode 100755 index 000000000..7fe66703a --- /dev/null +++ b/bin/oxfordshire/archive-old-enquiries @@ -0,0 +1,29 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +require 5.8.0; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../../setenv.pl"; +} + +use FixMyStreet::Script::ArchiveOldEnquiries; +use Getopt::Long::Descriptive; + +my ($opts, $usage) = describe_options( + '%c %o', + ['commit|c', "actually close reports and send emails. Omitting this flag will do a dry-run"], + ['body|b=s', "which body ID to close reports for"], + ['cobrand=s', "which cobrand template to use for sent emails"], + ['closure-cutoff=s', "Anything before this will be closed with no email"], + ['email-cutoff=s', "Anything before this will be closed with an email sent to the reporter"], + ['limit|l=s', "limit to a certain number of reports/users to be closed"], + ['help|h', "print usage message and exit" ], +); +print($usage->text), exit if $opts->help; + +FixMyStreet::Script::ArchiveOldEnquiries::archive($opts); diff --git a/bin/oxfordshire/open311_service_request_update.cgi b/bin/oxfordshire/open311_service_request_update.cgi index 87b14fb98..8fb190e0e 100755 --- a/bin/oxfordshire/open311_service_request_update.cgi +++ b/bin/oxfordshire/open311_service_request_update.cgi @@ -102,7 +102,7 @@ XML foreach my $row(@{$ary_ref}) { if (defined $row) { my ($id, $service_req_id, $updated_at, $status, $desc) = map { prepare_for_xml($_) } @$row; - $updated_at=~s/(\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d)/${1}T${2}Z/; # for now assume OCC in Zulu time + $updated_at = get_utc_iso8601_string($updated_at); # value from the DB is in server-local time, convert to UTC. $xml.= <<XML; <request_update> <update_id>$id</update_id> diff --git a/bin/oxfordshire/open311_services.pm b/bin/oxfordshire/open311_services.pm index 12d0754fa..9be598751 100644 --- a/bin/oxfordshire/open311_services.pm +++ b/bin/oxfordshire/open311_services.pm @@ -10,6 +10,8 @@ use CGI; use Encode qw(from_to); use DBI; use Time::Piece; +use Time::Local qw(timelocal); +use POSIX qw(strftime); ################################################################### @@ -145,6 +147,20 @@ sub get_date_or_nothing { return $d; } +#------------------------------------------------------------------ +# get_utc_iso8601_string +# Takes a local date/time string and converts it to UTC, returning +# a ISO8601-format string. +# expected format: YYYY-MM-DD HH:MM:SS +# e.g.: 2016-04-01 13:37:42 -> 2016-04-01T12:37:42Z +#------------------------------------------------------------------ +sub get_utc_iso8601_string { + my $datetime = shift; + $datetime =~ s{(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)}{ + strftime "%Y-%m-%dT%H:%M:%SZ", gmtime(timelocal($6, $5, $4, $3, int($2)-1, int($1)-1900)); + }e; + return $datetime; +} 1; diff --git a/bin/site-specific-install.sh b/bin/site-specific-install.sh index 007cd1839..d780b7f94 100644 --- a/bin/site-specific-install.sh +++ b/bin/site-specific-install.sh @@ -1,7 +1,7 @@ #!/bin/sh # Set this to the version we want to check out -VERSION=${VERSION_OVERRIDE:-v2.0.1} +VERSION=${VERSION_OVERRIDE:-v2.0.4} PARENT_SCRIPT_URL=https://github.com/mysociety/commonlib/blob/master/bin/install-site.sh diff --git a/bin/update-schema b/bin/update-schema index 479a55c8e..171b87576 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -194,6 +194,9 @@ else { # By querying the database schema, we can see where we're currently at # (assuming schema change files are never half-applied, which should be the case) sub get_db_version { + return '0050' if table_exists('defect_types'); + return '0049' if column_exists('response_priorities', 'external_id'); + return '0048' if column_exists('response_templates', 'state'); return '0047' if column_exists('response_priorities', 'description'); return '0046' if column_exists('users', 'extra'); return '0045' if table_exists('response_priorities'); |