aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r--perllib/FixMyStreet/DB/Result/Alert.pm31
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm32
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm53
-rw-r--r--perllib/FixMyStreet/DB/Result/Questionnaire.pm28
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm1
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm1
7 files changed, 68 insertions, 80 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm
index ca9ad45c2..fc84c8fd5 100644
--- a/perllib/FixMyStreet/DB/Result/Alert.pm
+++ b/perllib/FixMyStreet/DB/Result/Alert.pm
@@ -77,22 +77,21 @@ with 'FixMyStreet::Roles::Abuser';
my $tz = DateTime::TimeZone->new( name => "local" );
-
-sub whensubscribed_local {
- my $self = shift;
-
- return $self->whensubscribed
- ? $self->whensubscribed->set_time_zone($tz)
- : $self->whensubscribed;
-}
-
-sub whendisabled_local {
- my $self = shift;
-
- return $self->whendisabled
- ? $self->whendisabled->set_time_zone($tz)
- : $self->whendisabled;
-}
+my $tz_f;
+$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
+ if FixMyStreet->config('TIME_ZONE');
+
+my $stz = sub {
+ my ( $orig, $self ) = ( shift, shift );
+ my $s = $self->$orig(@_);
+ return $s unless $s && UNIVERSAL::isa($s, "DateTime");
+ $s->set_time_zone($tz);
+ $s->set_time_zone($tz_f) if $tz_f;
+ return $s;
+};
+
+around whensubscribed => $stz;
+around whendisabled => $stz;
=head2 confirm
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 33fbb9356..eb9e52a65 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -116,23 +116,21 @@ with 'FixMyStreet::Roles::Abuser';
my $tz = DateTime::TimeZone->new( name => "local" );
-sub created_local {
- my $self = shift;
-
- return $self->created
- ? $self->created->set_time_zone($tz)
- : $self->created;
-}
-
-sub confirmed_local {
- my $self = shift;
-
- # if confirmed is null then it doesn't get inflated so don't
- # try and set the timezone
- return $self->confirmed
- ? $self->confirmed->set_time_zone($tz)
- : $self->confirmed;
-}
+my $tz_f;
+$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
+ if FixMyStreet->config('TIME_ZONE');
+
+my $stz = sub {
+ my ( $orig, $self ) = ( shift, shift );
+ my $s = $self->$orig(@_);
+ return $s unless $s && UNIVERSAL::isa($s, "DateTime");
+ $s->set_time_zone($tz);
+ $s->set_time_zone($tz_f) if $tz_f;
+ return $s;
+};
+
+around created => $stz;
+around confirmed => $stz;
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 24aa12944..ec15600b6 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -301,6 +301,7 @@ sub all_states {
'confirmed' => 1,
'investigating' => 1,
'in progress' => 1,
+ 'planned' => 1,
'action scheduled' => 1,
'fixed' => 1,
'fixed - council' => 1,
@@ -342,37 +343,23 @@ sub council_states {
my $tz = DateTime::TimeZone->new( name => "local" );
-sub confirmed_local {
- my $self = shift;
-
- return $self->confirmed
- ? $self->confirmed->set_time_zone($tz)
- : $self->confirmed;
-}
-
-sub created_local {
- my $self = shift;
-
- return $self->created
- ? $self->created->set_time_zone($tz)
- : $self->created;
-}
-
-sub whensent_local {
- my $self = shift;
+my $tz_f;
+$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
+ if FixMyStreet->config('TIME_ZONE');
- return $self->whensent
- ? $self->whensent->set_time_zone($tz)
- : $self->whensent;
-}
-
-sub lastupdate_local {
- my $self = shift;
+my $stz = sub {
+ my ( $orig, $self ) = ( shift, shift );
+ my $s = $self->$orig(@_);
+ return $s unless $s && UNIVERSAL::isa($s, "DateTime");
+ $s->set_time_zone($tz);
+ $s->set_time_zone($tz_f) if $tz_f;
+ return $s;
+};
- return $self->lastupdate
- ? $self->lastupdate->set_time_zone($tz)
- : $self->lastupdate;
-}
+around created => $stz;
+around confirmed => $stz;
+around whensent => $stz;
+around lastupdate => $stz;
around service => sub {
my ( $orig, $self ) = ( shift, shift );
@@ -574,7 +561,7 @@ meta data about the report.
sub meta_line {
my ( $problem, $c ) = @_;
- my $date_time = Utils::prettify_dt( $problem->confirmed_local );
+ my $date_time = Utils::prettify_dt( $problem->confirmed );
my $meta = '';
# FIXME Should be in cobrand
@@ -709,7 +696,7 @@ sub duration_string {
my ( $problem, $c ) = @_;
my $body = $problem->body( $c );
return sprintf(_('Sent to %s %s later'), $body,
- Utils::prettify_duration($problem->whensent_local->epoch - $problem->confirmed_local->epoch, 'minute')
+ Utils::prettify_duration($problem->whensent->epoch - $problem->confirmed->epoch, 'minute')
);
}
@@ -832,8 +819,8 @@ sub as_hashref {
is_fixed => $self->fixed_states->{ $self->state } ? 1 : 0,
photo => $self->get_photo_params,
meta => $self->confirmed ? $self->meta_line( $c ) : '',
- confirmed_pp => $self->confirmed ? Utils::prettify_dt( $self->confirmed_local, 1 ): '',
- created_pp => Utils::prettify_dt( $self->created_local, 1 ),
+ confirmed_pp => $self->confirmed ? $c->cobrand->prettify_dt( $self->confirmed ): '',
+ created_pp => $c->cobrand->prettify_dt( $self->created ),
};
}
diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
index b6791603a..fcaa17d99 100644
--- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
@@ -44,23 +44,25 @@ __PACKAGE__->belongs_to(
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NGlSRjoBpDoIvK3EueqN6Q
use DateTime::TimeZone;
+use Moose;
+use namespace::clean -except => [ 'meta' ];
my $tz = DateTime::TimeZone->new( name => "local" );
-sub whensent_local {
- my $self = shift;
+my $tz_f;
+$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
+ if FixMyStreet->config('TIME_ZONE');
- return $self->whensent
- ? $self->whensent->set_time_zone($tz)
- : $self->whensent;
-}
+my $stz = sub {
+ my ( $orig, $self ) = ( shift, shift );
+ my $s = $self->$orig(@_);
+ return $s unless $s && UNIVERSAL::isa($s, "DateTime");
+ $s->set_time_zone($tz);
+ $s->set_time_zone($tz_f) if $tz_f;
+ return $s;
+};
-sub whenanswered_local {
- my $self = shift;
-
- return $self->whenanswered
- ? $self->whenanswered->set_time_zone($tz)
- : $self->whenanswered;
-}
+around whensent => $stz;
+around whenanswered => $stz;
1;
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index 8e9b3d17e..f2b86725d 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -236,6 +236,7 @@ sub _send_aggregated_alert_email(%) {
{
_template_ => $template,
_parameters_ => \%data,
+ _line_indent => $cobrand->email_indent,
From => [ $sender, _($cobrand->contact_name) ],
To => $data{alert_email},
},
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 116151753..dc1c5c248 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -269,7 +269,7 @@ sub send_reports {
# Template variables for the email
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/;
+ map { $h{$_} = $row->user->$_ || '' } qw/email phone/;
$h{confirmed} = DateTime::Format::Pg->format_datetime( $row->confirmed->truncate (to => 'second' ) )
if $row->confirmed;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
index 1b9521a9f..8d811180e 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
@@ -101,6 +101,7 @@ sub send_questionnaires_period {
{
_template_ => $template,
_parameters_ => \%h,
+ _line_indent => $cobrand->email_indent,
To => [ [ $row->user->email, $row->name ] ],
From => [ $sender, $sender_name ],
},