aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xperllib/CronFns.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm8
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm7
-rw-r--r--perllib/FixMyStreet/SendReport/Zurich.pm53
-rwxr-xr-xtemplates/email/zurich/submit-external.txt8
-rwxr-xr-xtemplates/email/zurich/submit-feedback-pending.txt10
-rwxr-xr-xtemplates/email/zurich/submit-in-progress.txt10
-rwxr-xr-xtemplates/email/zurich/submit.txt10
9 files changed, 107 insertions, 6 deletions
diff --git a/perllib/CronFns.pm b/perllib/CronFns.pm
index 0573b788d..6bf698d2b 100755
--- a/perllib/CronFns.pm
+++ b/perllib/CronFns.pm
@@ -34,6 +34,7 @@ sub site {
my $base_url = shift;
my $site = 'fixmystreet';
$site = 'emptyhomes' if $base_url =~ 'emptyhomes';
+ $site = 'zurich' if $base_url =~ 'zurich';
return $site;
}
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index d70e785d7..c67d946ad 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -38,6 +38,11 @@ sub show_unconfirmed_reports {
1;
}
+sub get_body_sender {
+ my ( $self, $body, $category ) = @_;
+ return { method => 'Zurich' };
+}
+
# Specific administrative displays
sub admin_pages {
@@ -293,6 +298,7 @@ sub admin_report_edit {
# If they clicked the no more updates button, we're done.
if ($c->req->param('no_more_updates')) {
$problem->bodies_str( $body->parent->id );
+ $problem->whensent( undef );
$problem->state( 'planned' );
$problem->update;
# log here
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 6cecdea7e..897a7e732 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -222,8 +222,10 @@ sub send_reports {
my $base_url = mySociety::Config::get('BASE_URL');
my $site = CronFns::site($base_url);
+ my $states = [ 'confirmed', 'fixed' ];
+ $states = [ 'unconfirmed', 'confirmed', 'in progress', 'planned', 'closed' ] if $site eq 'zurich';
my $unsent = FixMyStreet::App->model("DB::Problem")->search( {
- state => [ 'confirmed', 'fixed' ],
+ state => $states,
whensent => undef,
bodies_str => { '!=', undef },
} );
@@ -252,10 +254,12 @@ sub send_reports {
my $email_base_url = $cobrand->base_url_for_report($row);
my %h = map { $_ => $row->$_ } qw/id title detail name category latitude longitude used_map/;
map { $h{$_} = $row->user->$_ } qw/email phone/;
- $h{confirmed} = DateTime::Format::Pg->format_datetime( $row->confirmed->truncate (to => 'second' ) );
+ $h{confirmed} = DateTime::Format::Pg->format_datetime( $row->confirmed->truncate (to => 'second' ) )
+ if $row->confirmed;
$h{query} = $row->postcode;
$h{url} = $email_base_url . $row->url;
+ $h{admin_url} = $cobrand->admin_base_url . 'report_edit/' . $row->id;
$h{phone_line} = $h{phone} ? _('Phone:') . " $h{phone}\n\n" : '';
if ($row->photo) {
$h{has_photo} = _("This web page also contains a photo of the problem, provided by the user.") . "\n\n";
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index b7c15a643..2a580c0d5 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -55,6 +55,11 @@ sub get_template {
return $template;
}
+sub send_from {
+ my ( $self, $row ) = @_;
+ return [ $row->user->email, $row->name ];
+}
+
sub send {
my $self = shift;
my ( $row, $h ) = @_;
@@ -77,7 +82,7 @@ sub send {
_template_ => $self->get_template( $row ),
_parameters_ => $h,
To => $self->to,
- From => [ $row->user->email, $row->name ],
+ From => $self->send_from( $row ),
},
mySociety::Config::get('CONTACT_EMAIL'),
\@recips,
diff --git a/perllib/FixMyStreet/SendReport/Zurich.pm b/perllib/FixMyStreet/SendReport/Zurich.pm
new file mode 100644
index 000000000..7bf6fe1a3
--- /dev/null
+++ b/perllib/FixMyStreet/SendReport/Zurich.pm
@@ -0,0 +1,53 @@
+package FixMyStreet::SendReport::Zurich;
+
+use Moose;
+
+BEGIN { extends 'FixMyStreet::SendReport::Email'; }
+
+sub build_recipient_list {
+ my ( $self, $row, $h ) = @_;
+
+ # Only one body ever, most of the time with an email endpoint
+ my $body = @{ $self->bodies }[0];
+ my $body_email = $body->endpoint;
+
+ my @bodies = $body->bodies;
+ if ($body->parent && @bodies) {
+ # Division, might have an individual contact email address
+ my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ body_id => $body->id,
+ category => $row->category
+ } );
+ $body_email = $contact->email if $contact->email;
+ }
+
+ push @{ $self->to }, [ $body_email, $body->name ];
+ return $body_email;
+}
+
+sub get_template {
+ my ( $self, $row ) = @_;
+
+ my $template;
+ if ( $row->state eq 'unconfirmed' || $row->state eq 'confirmed' ) {
+ $template = 'submit.txt';
+ } elsif ( $row->state eq 'in progress' ) {
+ $template = 'submit-in-progress.txt';
+ } elsif ( $row->state eq 'planned' ) {
+ $template = 'submit-feedback-pending.txt';
+ } elsif ( $row->state eq 'closed' ) {
+ $template = 'submit-external.txt';
+ }
+
+ my $template_path = FixMyStreet->path_to( "templates", "email", "zurich", $template )->stringify;
+ $template = Utils::read_file( $template_path );
+ return $template;
+}
+
+# Zurich emails come from the site itself
+sub send_from {
+ my ( $self, $row ) = @_;
+ return [ FixMyStreet->config('CONTACT_EMAIL'), FixMyStreet->config('CONTACT_NAME') ];
+}
+
+1;
diff --git a/templates/email/zurich/submit-external.txt b/templates/email/zurich/submit-external.txt
new file mode 100755
index 000000000..0775f7728
--- /dev/null
+++ b/templates/email/zurich/submit-external.txt
@@ -0,0 +1,8 @@
+Subject: FixMyZurich: New report #<?=$values['id']?>
+
+Dear <?=$values['bodies_name']?>,
+
+This report has been sent to you by Stadt Zurich to be dealt with.
+
+Public URL: <?=$values['url']?>
+
diff --git a/templates/email/zurich/submit-feedback-pending.txt b/templates/email/zurich/submit-feedback-pending.txt
new file mode 100755
index 000000000..ff2e8e8b1
--- /dev/null
+++ b/templates/email/zurich/submit-feedback-pending.txt
@@ -0,0 +1,10 @@
+Subject: FixMyZurich: report #<?=$values['id']?> pending feedback
+
+Dear <?=$values['bodies_name']?>,
+
+This report has been sent back to you by the subdivision for final response and closure.
+
+Public URL: <?=$values['url']?>
+
+Admin URL: <?=$values['admin_url']?>
+
diff --git a/templates/email/zurich/submit-in-progress.txt b/templates/email/zurich/submit-in-progress.txt
new file mode 100755
index 000000000..c8d259e09
--- /dev/null
+++ b/templates/email/zurich/submit-in-progress.txt
@@ -0,0 +1,10 @@
+Subject: FixMyZurich: New report #<?=$values['id']?>
+
+Dear <?=$values['bodies_name']?>,
+
+This report has been sent to you by your division to be dealt with.
+
+Public URL: <?=$values['url']?>
+
+Admin URL: <?=$values['admin_url']?>
+
diff --git a/templates/email/zurich/submit.txt b/templates/email/zurich/submit.txt
index 57663ef80..752d6c6b4 100755
--- a/templates/email/zurich/submit.txt
+++ b/templates/email/zurich/submit.txt
@@ -1,6 +1,10 @@
-Subject: Fix my Zurich: #<?=$values['ID']?>
+Subject: FixMyZurich: New report #<?=$values['id']?>
-<?=$values['url']?>
+Dear <?=$values['bodies_name']?>,
-<?=$values['detail']?>
+A new report has been submitted by a user.
+
+Public URL: <?=$values['url']?>
+
+Admin URL: <?=$values['admin_url']?>