aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/My.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/My.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm69
1 files changed, 69 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
new file mode 100644
index 000000000..19b3ffee0
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -0,0 +1,69 @@
+package FixMyStreet::App::Controller::My;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+FixMyStreet::App::Controller::My - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+=head2 index
+
+=cut
+
+sub my : Path : Args(0) {
+ my ( $self, $c ) = @_;
+
+ $c->detach( '/auth/redirect' ) unless $c->user;
+
+ my $p_page = $c->req->params->{p} || 1;
+ my $u_page = $c->req->params->{u} || 1;
+
+ my $pins = [];
+ my $problems = {};
+ my $rs = $c->user->problems->search( undef,
+ { rows => 50 } )->page( $p_page );
+
+ while ( my $problem = $rs->next ) {
+ 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_pager} = $rs->pager;
+ $c->stash->{problems} = $problems;
+
+ $rs = $c->user->comments->search(
+ { state => 'confirmed' },
+ { rows => 50 } )->page( $u_page );
+ my @updates = $rs->all;
+ $c->stash->{updates} = \@updates;
+ $c->stash->{updates_pager} = $rs->pager;
+
+ $c->stash->{page} = 'my';
+ FixMyStreet::Map::display_map(
+ $c,
+ latitude => $pins->[0]{latitude},
+ longitude => $pins->[0]{longitude},
+ pins => $pins,
+ any_zoom => 1,
+ )
+ if @$pins;
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;