From ee7770bb0130e2e0483af203c7410dad8269bdd7 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 23 Aug 2012 12:45:18 +0100 Subject: initial crude add support option for a problem --- perllib/FixMyStreet/App/Controller/Report.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index d36ba32fe..05c08100d 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -56,6 +56,17 @@ sub display : Path('') : Args(1) { $c->forward( 'format_problem_for_display' ); } +sub support : Path('support') : Args(1) { + my ( $self, $c, $id ) = @_; + + if ( $c->cobrand->can_support_problems && $c->user && $c->user->from_council ) { + $c->forward( 'load_problem_or_display_error', [ $id ] ); + $c->stash->{problem}->interest_count( $c->stash->{problem}->interest_count + 1 ); + $c->stash->{problem}->update; + } + $c->res->redirect( $c->uri_for( '', $id ) ); +} + sub load_problem_or_display_error : Private { my ( $self, $c, $id ) = @_; -- cgit v1.2.3 From 1aeb10621ead53f55740e332c00c94277107666b Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 27 Aug 2012 12:58:26 +0100 Subject: Display support count even if not logged in use a button for adding support rather than a link --- perllib/FixMyStreet/App/Controller/Report.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 05c08100d..4127b6247 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -56,15 +56,22 @@ sub display : Path('') : Args(1) { $c->forward( 'format_problem_for_display' ); } -sub support : Path('support') : Args(1) { - my ( $self, $c, $id ) = @_; +sub support : Path('support') : Args(0) { + my ( $self, $c ) = @_; + + my $id = $c->req->param('id'); + + my $uri = + $id + ? $c->uri_for( '/report', $id ) + : $c->uri_for('/'); - if ( $c->cobrand->can_support_problems && $c->user && $c->user->from_council ) { + if ( $id && $c->cobrand->can_support_problems && $c->user && $c->user->from_council ) { $c->forward( 'load_problem_or_display_error', [ $id ] ); $c->stash->{problem}->interest_count( $c->stash->{problem}->interest_count + 1 ); $c->stash->{problem}->update; } - $c->res->redirect( $c->uri_for( '', $id ) ); + $c->res->redirect( $uri ); } sub load_problem_or_display_error : Private { -- cgit v1.2.3 From 716c333de51d06e289f0dd798ec675b6466e336a Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 28 Aug 2012 13:08:56 +0100 Subject: remove race condition --- perllib/FixMyStreet/App/Controller/Report.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 4127b6247..57d27b3e4 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -68,8 +68,7 @@ sub support : Path('support') : Args(0) { if ( $id && $c->cobrand->can_support_problems && $c->user && $c->user->from_council ) { $c->forward( 'load_problem_or_display_error', [ $id ] ); - $c->stash->{problem}->interest_count( $c->stash->{problem}->interest_count + 1 ); - $c->stash->{problem}->update; + $c->stash->{problem}->update( { interest_count => \'interest_count +1' } ); } $c->res->redirect( $uri ); } -- cgit v1.2.3