aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report/Update.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-11-22 19:13:54 +0000
committerStruan Donald <struan@exo.org.uk>2012-11-22 19:13:54 +0000
commit0492b90bdb2a4666f85cdab3d8f636910bbe40c1 (patch)
treed81c72fd48b4551ff9259842af90c548fd6ce1f1 /perllib/FixMyStreet/App/Controller/Report/Update.pm
parenta34f9a98ba599d6bdb790a524cf44308ba735509 (diff)
If we are sending updates to an external system we need to record
the state the update left the problem in so we can send the correct status with the update. If we don't do this then it's possible that we get an update that marks the problem as fixed as fixed and another that marks it as open and we send both with a status of open.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index c3abdaf3c..3fc8bfee8 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -199,8 +199,23 @@ sub process_update : Private {
$params{state} = 'fixed - council'
if $params{state} eq 'fixed' && $c->user && $c->user->belongs_to_council( $update->problem->council );
$update->problem_state( $params{state} );
+ } else {
+ # we do this so we have a record of the state of the problem at this point
+ # for use when sending updates to external parties
+ if ( $update->mark_fixed ) {
+ $update->problem_state( 'fixed - user' );
+ } elsif ( $update->mark_open ) {
+ $update->problem_state( 'confirmed' );
+ # if there is not state param and neither of the above conditions apply
+ # then we are not changing the state of the problem so can use the current
+ # problem state
+ } else {
+ my $problem = $c->stash->{problem} || $update->problem;
+ $update->problem_state( $problem->state );
+ }
}
+
my @extra; # Next function fills this, but we don't need it here.
# This is just so that the error checkign for these extra fields runs.
# TODO Use extra here as it is used on reports.