aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-04-11 21:48:02 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-04-11 21:48:02 +0100
commit9fde903b6f9d2fa70e666cd5d9f864cb275bffe2 (patch)
tree5abc436101f4635e5b08f005a08927b05de1b77d
parent5134dfd97c0190c5cecb6438baf80c9b72388527 (diff)
parent0cc74ca4240d96747ea8bc6f654ae19e9efdd2a0 (diff)
Merge branch 'open311-update-problem-state'
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm32
-rw-r--r--t/open311/getservicerequestupdates.t2
3 files changed, 18 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b8c484f9..bb6e0e94e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,7 @@
- Set a session timezone in case database server is set differently.
- Fix SQL error on update edit admin page in cobrands. #2049
- Improve chart display in old IE versions. #2005
+ - Improve handling of Open311 state changes. #2069
- Admin improvements:
- Inspectors can set non_public status of reports. #1992
- Default start date is shown on the dashboard.
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index cee1a629f..b3b165d27 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -138,22 +138,22 @@ sub update_comments {
$open311->add_media($request->{media_url}, $comment)
if $request->{media_url};
- # if the comment is older than the last update
- # do not change the status of the problem as it's
- # tricky to determine the right thing to do.
- # Allow the same time in case report/update created at same time (in external system)
- if ( $comment->created >= $p->lastupdate ) {
- # don't update state unless it's an allowed state and it's
- # actually changing the state of the problem
- if ( FixMyStreet::DB::Result::Problem->visible_states()->{$state} && $p->state ne $state &&
- # For Oxfordshire, don't allow changes back to Open from other open states
- !( $body->areas->{$AREA_ID_OXFORDSHIRE} && $state eq 'confirmed' && $p->is_open ) &&
- # Don't let it change between the (same in the front end) fixed states
- !( $p->is_fixed && FixMyStreet::DB::Result::Problem->fixed_states()->{$state} ) ) {
- if ($p->is_visible) {
- $p->state($state);
- }
- $comment->problem_state($state);
+ # don't update state unless it's an allowed state
+ if ( FixMyStreet::DB::Result::Problem->visible_states()->{$state} &&
+ # For Oxfordshire, don't allow changes back to Open from other open states
+ !( $body->areas->{$AREA_ID_OXFORDSHIRE} && $state eq 'confirmed' && $p->is_open ) &&
+ # Don't let it change between the (same in the front end) fixed states
+ !( $p->is_fixed && FixMyStreet::DB::Result::Problem->fixed_states()->{$state} ) ) {
+
+ $comment->problem_state($state);
+
+ # if the comment is older than the last update do not
+ # change the status of the problem as it's tricky to
+ # determine the right thing to do. Allow the same time in
+ # case report/update created at same time (in external
+ # system). Only do this if the report is currently visible.
+ if ( $comment->created >= $p->lastupdate && $p->state ne $state && $p->is_visible ) {
+ $p->state($state);
}
}
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index ec2ffb593..cc319cbdc 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -150,7 +150,7 @@ for my $test (
comment_status => 'OPEN',
mark_fixed=> 0,
mark_open => 0,
- problem_state => undef,
+ problem_state => 'confirmed',
end_state => 'confirmed',
},
{