aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Problem.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2017-02-15 13:41:38 +0000
committerDave Arter <davea@mysociety.org>2017-02-15 13:41:38 +0000
commit54af489f0fe985dfc433f0b8a3ab226a470a6023 (patch)
tree29a0a89f65016cd0fc4900ea7491da67ddd2389a /perllib/FixMyStreet/DB/Result/Problem.pm
parente198a5b8ba63fb1bae68132d2a81fd6cd4ecf69a (diff)
parent8e6f6a1818b4f998d48f157387d2314bb8c86f8a (diff)
Merge branch 'issues/forcouncils/51-close-old-reports'
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm40
1 files changed, 40 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 0092dd8b5..97cb28fe8 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -182,6 +182,8 @@ use Utils;
use FixMyStreet::Map::FMS;
use LWP::Simple qw($ua);
use RABX;
+use URI;
+use URI::QueryParam;
my $IM = eval {
require Image::Magick;
@@ -511,6 +513,30 @@ sub admin_url {
return $cobrand->admin_base_url . '/report_edit/' . $self->id;
}
+=head2 tokenised_url
+
+Return a url for this problem report that logs a user in
+
+=cut
+
+sub tokenised_url {
+ my ($self, $user, $params) = @_;
+
+ my $token = FixMyStreet::App->model('DB::Token')->create(
+ {
+ scope => 'email_sign_in',
+ data => {
+ id => $self->id,
+ email => $user->email,
+ r => $self->url,
+ p => $params,
+ }
+ }
+ );
+
+ return "/M/". $token->token;
+}
+
=head2 is_open
Returns 1 if the problem is in a open state otherwise 0.
@@ -659,6 +685,20 @@ sub body {
return $body;
}
+
+=head2 time_ago
+ Returns how long ago a problem was reported in an appropriately
+ prettified duration, depending on the duration.
+=cut
+
+sub time_ago {
+ my ( $self, $date ) = @_;
+ $date ||= 'confirmed';
+ my $duration = time() - $self->$date->epoch;
+
+ return Utils::prettify_duration( $duration );
+}
+
=head2 response_templates
Returns all ResponseTemplates attached to this problem's bodies, in alphabetical