aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-13 12:42:32 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-13 12:42:32 +0100
commit76715723f615a5858587586df395072745f9e5cb (patch)
treee20adac83ca5a01ff211b3fff4e0943e214df23d
parent959acf33e06ea8ea3bae7fa89e800dfd8c45621e (diff)
make problem report date pretty
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm15
-rw-r--r--t/app/controller/contact.t2
-rw-r--r--templates/web/default/contact/index.html4
3 files changed, 18 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index 2980b3811..9a19f471e 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -80,7 +80,20 @@ sub determine_contact_type : Private {
$update_id = undef unless $update_id && $update_id =~ /^[1-9]\d*$/;
if ($id) {
- my $problem = $c->model('DB::Problem')->find( { id => $id } );
+ my $problem = $c->model('DB::Problem')->find(
+ { id => $id },
+ {
+ 'select' => [
+ 'title', 'detail', 'name',
+ 'anonymous',
+ 'user_id',
+ {
+ extract => 'epoch from confirmed',
+ -as => 'confirmed'
+ }
+ ]
+ }
+ );
if ( $update_id ) {
# my $u = dbh()->selectrow_hashref(
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 60e330776..d4c31bd20 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -24,6 +24,7 @@ subtest 'check reporting a problem displays correctly' => sub {
title => 'Some problem or other',
detail => 'More detail on the problem',
postcode => 'EH99 1SP',
+ confirmed => '2011-05-04 10:44:28.145168',
latitude => 0,
longitude => 0,
areas => 0,
@@ -41,6 +42,7 @@ subtest 'check reporting a problem displays correctly' => sub {
$mech->content_contains( 'reporting the following problem' );
$mech->content_contains( 'Some problem or other' );
$mech->content_contains( 'Reported by A User' );
+ $mech->content_contains( 'Reported by A User at 10:44, Wednesday 4 May 2011' );
$problem->delete;
};
diff --git a/templates/web/default/contact/index.html b/templates/web/default/contact/index.html
index 5ab5bad8c..dc5c43fdf 100644
--- a/templates/web/default/contact/index.html
+++ b/templates/web/default/contact/index.html
@@ -22,7 +22,7 @@
[% IF update.anonymous %]
[% tprintf( loc('Update below added anonymously at %s'), update.confirmed ) %]
[% ELSE %]
- [% tprintf( loc('Update below added by %s at %s'), update.name, problem.confirmed ) | html %]
+ [% tprintf( loc('Update below added by %s at %s'), update.name, prettify_epoch( update.confirmed ) ) | html %]
[% END %]
</p>
@@ -46,7 +46,7 @@
[% IF problem.anonymous %]
[% tprintf( loc('Reported anonymously at %s'), problem.confirmed ) %]
[% ELSE %]
- [% tprintf( loc('Reported by %s at %s'), problem.user.name, problem.confirmed ) | html %]
+ [% tprintf( loc('Reported by %s at %s'), problem.user.name, prettify_epoch( problem.confirmed ) ) | html %]
[% END %]
</p>