diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 25 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 10 | ||||
-rw-r--r-- | perllib/Utils.pm | 23 |
3 files changed, 47 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index 79d5c5681..8cb807e09 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -22,7 +22,32 @@ Catalyst Controller. sub my : Path : Args(0) { my ( $self, $c ) = @_; + $c->detach( '/auth/redirect' ) unless $c->user; + + my $pins = []; + my $problems = {}; + foreach my $problem ( $c->user->problems ) { + push @$pins, { + latitude => $problem->latitude, + longitude => $problem->longitude, + colour => $problem->state eq 'fixed' ? 'green' : 'red', + id => $problem->id, + title => $problem->title, + }; + push @{ $problems->{$problem->state} }, $problem; + } + + $c->stash->{problems} = $problems; + + FixMyStreet::Map::display_map( + $c, + latitude => $pins->[0]{latitude}, + longitude => $pins->[0]{longitude}, + pins => $pins, + any_zoom => 1, + ) + if @$pins; } __PACKAGE__->meta->make_immutable; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index da23802c3..ff730958a 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -364,8 +364,7 @@ sub meta_line { return $meta; } -# TODO Some/much of this could be moved to the template -sub duration_string { +sub body { my ( $problem, $c ) = @_; my $body; if ($problem->external_body) { @@ -387,6 +386,13 @@ sub duration_string { } @councils ); } + return $body; +} + +# TODO Some/much of this could be moved to the template +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') ); diff --git a/perllib/Utils.pm b/perllib/Utils.pm index 44234607f..39c251876 100644 --- a/perllib/Utils.pm +++ b/perllib/Utils.pm @@ -210,20 +210,25 @@ sub cleanup_text { } sub prettify_epoch { - my ($s, $short) = @_; + my ( $s, $type ) = @_; + $type = 'short' if $type eq '1'; + my @s = localtime($s); - my $tt = strftime('%H:%M', @s); + my $tt = ''; + $tt = strftime('%H:%M', @s) unless $type eq 'date'; my @t = localtime(); if (strftime('%Y%m%d', @s) eq strftime('%Y%m%d', @t)) { - $tt = "$tt " . _('today'); - } elsif (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) { - $tt = "$tt, " . decode_utf8(strftime('%A', @s)); - } elsif ($short) { - $tt = "$tt, " . decode_utf8(strftime('%e %b %Y', @s)); + return "$tt " . _('today'); + } + $tt .= ', ' unless $type eq 'date'; + if (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) { + $tt .= decode_utf8(strftime('%A', @s)); + } elsif ($type eq 'short') { + $tt .= decode_utf8(strftime('%e %b %Y', @s)); } elsif (strftime('%Y', @s) eq strftime('%Y', @t)) { - $tt = "$tt, " . decode_utf8(strftime('%A %e %B %Y', @s)); + $tt .= decode_utf8(strftime('%A %e %B %Y', @s)); } else { - $tt = "$tt, " . decode_utf8(strftime('%a %e %B %Y', @s)); + $tt .= decode_utf8(strftime('%a %e %B %Y', @s)); } return $tt; } |