aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-01-16 11:47:20 +0000
committerStruan Donald <struan@exo.org.uk>2013-01-16 11:47:20 +0000
commit682db36dca4db6c0682deeb4fb704e8cf222e38c (patch)
tree5811b7e2288f48b0bc814f7f505e19cb705294d9 /perllib/Open311
parent257b658e49da3665a426f1c98d9760b0d53b8d3d (diff)
parent3c4c0ec2f55d82502169d2313745920850efdc99 (diff)
Merge branch 'bromley-new-statuses'
Conflicts: bin/send-comments conf/crontab.ugly db/schema.sql perllib/FixMyStreet/App/Controller/Admin.pm perllib/FixMyStreet/DB/Result/Open311conf.pm perllib/FixMyStreet/DB/ResultSet/Problem.pm perllib/Open311.pm t/app/controller/report_updates.t t/open311.t templates/web/default/report/display.html templates/web/default/report/updates.html templates/web/fixmystreet/report/display.html
Diffstat (limited to 'perllib/Open311')
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm32
1 files changed, 26 insertions, 6 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 0b4e037fd..e337c0f57 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -113,12 +113,14 @@ sub update_comments {
# do not change the status of the problem as it's
# tricky to determine the right thing to do.
if ( $comment->created_local > $p->lastupdate_local ) {
- if ( $p->is_open and lc($request->{status}) eq 'closed' ) {
- $p->state( 'fixed - council' );
- $comment->problem_state( 'fixed - council' );
- } elsif ( ( $p->is_closed || $p->is_fixed ) and lc($request->{status}) eq 'open' ) {
- $p->state( 'confirmed' );
- $comment->problem_state( 'confirmed' );
+ my $state = $self->map_state( $request->{status} );
+
+ # 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->council_states()->{$state} && $p->state ne $state &&
+ !( $p->is_fixed && FixMyStreet::DB::Result::Problem->fixed_states()->{$state} ) ) {
+ $p->state($state);
+ $comment->problem_state($state);
}
}
@@ -146,4 +148,22 @@ sub update_comments {
return 1;
}
+sub map_state {
+ my $self = shift;
+ my $incoming_state = shift;
+
+ $incoming_state = lc($incoming_state);
+ $incoming_state =~ s/_/ /g;
+
+ my %state_map = (
+ fixed => 'fixed - council',
+ 'not councils responsibility' => 'not responsible',
+ 'no further action' => 'unable to fix',
+ open => 'confirmed',
+ closed => 'fixed - council'
+ );
+
+ return $state_map{$incoming_state} || $incoming_state;
+}
+
1;