From c9773705e4c611363474144f69182ad421187242 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 16 Jun 2011 12:17:35 +0100 Subject: handle new states in report display and updating --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 2f1d88d08..88b53494b 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -56,7 +56,7 @@ sub update_problem : Private { my $problem = $c->stash->{problem} || $update->problem; if ( $update->mark_fixed ) { - $problem->state('fixed'); + $problem->state('fixed - user'); if ( $update->user->id == $problem->user->id ) { $problem->send_questionnaire(0); -- cgit v1.2.3 From 59e5a595bd0a903f25eb6210209cec5afe1f699c Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 23 Jun 2011 14:06:03 +0100 Subject: prevent non authority users from changing the state on updates --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 88b53494b..02d111d9f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -180,6 +180,15 @@ return false. sub check_for_errors : Private { my ( $self, $c ) = @_; + # they have to be an authority user to update the state + if ( $c->req->param('state') ) { + unless ( $c->user && $c->user->from_authority ) { + $c->stash->{errors} ||= []; + push @{ $c->stash->{errors} }, _('There was a problem with your update. Please try again.'); + return; + } + } + # let the model check for errors my %field_errors = ( %{ $c->stash->{update_user}->check_for_errors }, -- cgit v1.2.3 From 159fa8ad9e2427d8b20586baec4c260a0c71b57c Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 23 Jun 2011 15:46:55 +0100 Subject: update problem status from update --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 354690949..a131fbd35 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -65,6 +65,10 @@ sub update_problem : Private { } } + if ( $update->problem_state ) { + $problem->state( $update->problem_state ); + } + $problem->lastupdate( \'ms_current_timestamp()' ); $problem->update; @@ -126,7 +130,7 @@ sub process_update : Private { my ( $self, $c ) = @_; my %params = - map { $_ => scalar $c->req->param($_) } ( 'update', 'name', 'fixed' ); + map { $_ => scalar $c->req->param($_) } ( 'update', 'name', 'fixed', 'state' ); $params{update} = Utils::cleanup_text( $params{update}, { allow_multiline => 1 } ); @@ -152,6 +156,12 @@ sub process_update : Private { } ); + if ( $params{state} ) { + $params{state} = 'fixed - council' + if $params{state} eq 'fixed' && $c->user && $c->user->from_authority; + $update->problem_state( $params{state} ); + } + $c->stash->{update} = $update; $c->stash->{add_alert} = $c->req->param('add_alert'); -- cgit v1.2.3 From fb56c38856fe33c971903ab0efde1cf5d4829426 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 23 Jun 2011 16:34:19 +0100 Subject: check that state is permitted --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 41bc3a4bd..5421385fb 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -181,11 +181,18 @@ sub check_for_errors : Private { # they have to be an authority user to update the state if ( $c->req->param('state') ) { - unless ( $c->user && $c->user->from_authority ) { + my $error = 0; + $error = 1 unless $c->user && $c->user->from_authority; + + my $state = $c->req->param('state'); + $error = 1 unless ( grep { $state eq $_ } ( qw/closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) ); + + if ( $error ) { $c->stash->{errors} ||= []; push @{ $c->stash->{errors} }, _('There was a problem with your update. Please try again.'); return; } + } # let the model check for errors -- cgit v1.2.3 From a20fc533b0f10646814742f1348c5f9141217efa Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 27 Jun 2011 11:03:57 +0100 Subject: change to use from_council in users table and store the council id in there so we can check that the problem is for the council the user is from --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 2d810d871..652694595 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -153,7 +153,8 @@ sub process_update : Private { if ( $params{state} ) { $params{state} = 'fixed - council' - if $params{state} eq 'fixed' && $c->user && $c->user->from_authority; + if $params{state} eq 'fixed' && $c->user && $c->user->from_council + && $c->user->from_council == $update->problem->council; $update->problem_state( $params{state} ); } @@ -177,7 +178,7 @@ sub check_for_errors : Private { # they have to be an authority user to update the state if ( $c->req->param('state') ) { my $error = 0; - $error = 1 unless $c->user && $c->user->from_authority; + $error = 1 unless $c->user && $c->user->from_council && $c->user->from_council == $c->stash->{update}->problem->council; my $state = $c->req->param('state'); $error = 1 unless ( grep { $state eq $_ } ( qw/closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) ); -- cgit v1.2.3 From 0c3c4a0be17118ff4d8e01168df5938a947f28f6 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 27 Jun 2011 17:28:07 +0100 Subject: council users should be able to set state to confirmed --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 652694595..1ea0e88b4 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -181,7 +181,7 @@ sub check_for_errors : Private { $error = 1 unless $c->user && $c->user->from_council && $c->user->from_council == $c->stash->{update}->problem->council; my $state = $c->req->param('state'); - $error = 1 unless ( grep { $state eq $_ } ( qw/closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) ); + $error = 1 unless ( grep { $state eq $_ } ( qw/confirmed closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) ); if ( $error ) { $c->stash->{errors} ||= []; -- cgit v1.2.3 From f301d83e6bd7546b2f2a80067313dd17502581f8 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 28 Jun 2011 13:23:09 +0100 Subject: store correct old state in questionnaire when creator marks problem as fixed --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 1ea0e88b4..76bd89174 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -51,6 +51,9 @@ sub update_problem : Private { my $update = $c->stash->{update}; my $problem = $c->stash->{problem} || $update->problem; + # we may need this if we display the questionnaire + my $old_state = $problem->state; + if ( $update->mark_fixed ) { $problem->state('fixed - user'); @@ -75,6 +78,7 @@ sub update_problem : Private { $c->stash->{problem_id} = $problem->id; if ($display_questionnaire) { + $c->flash->{old_state} = $old_state; $c->detach('/questionnaire/creator_fixed'); } -- cgit v1.2.3 From e1801441beb37f37857c925a3c8c889653da4fe9 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 27 Jul 2011 13:54:46 +0100 Subject: allow council user to update state on problem sent to multiple councils --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 03130f60b..add9d1371 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -180,8 +180,7 @@ sub process_update : Private { if ( $params{state} ) { $params{state} = 'fixed - council' - if $params{state} eq 'fixed' && $c->user && $c->user->from_council - && $c->user->from_council == $update->problem->council; + if $params{state} eq 'fixed' && $c->user && $c->user->belongs_to_council( $update->problem->council ); $update->problem_state( $params{state} ); } @@ -205,7 +204,7 @@ sub check_for_errors : Private { # they have to be an authority user to update the state if ( $c->req->param('state') ) { my $error = 0; - $error = 1 unless $c->user && $c->user->from_council && $c->user->from_council == $c->stash->{update}->problem->council; + $error = 1 unless $c->user && $c->user->belongs_to_council( $c->stash->{update}->problem->council ); my $state = $c->req->param('state'); $error = 1 unless ( grep { $state eq $_ } ( qw/confirmed closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) ); -- cgit v1.2.3