diff options
Diffstat (limited to 'perllib/Open311')
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 7 | ||||
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 15 |
2 files changed, 11 insertions, 11 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 0751092fb..db2a452da 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -11,7 +11,7 @@ has start_date => ( is => 'ro', default => sub { undef } ); has end_date => ( is => 'ro', default => sub { undef } ); has suppress_alerts => ( is => 'rw', default => 0 ); has verbose => ( is => 'ro', default => 0 ); -has schema => ( is =>'ro', lazy => 1, default => sub { FixMyStreet::DB->connect } ); +has schema => ( is =>'ro', lazy => 1, default => sub { FixMyStreet::DB->schema->connect } ); Readonly::Scalar my $AREA_ID_BROMLEY => 2482; Readonly::Scalar my $AREA_ID_OXFORDSHIRE => 2237; @@ -142,7 +142,10 @@ sub update_comments { # 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 && + 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); diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index c5f17334b..764207626 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -6,7 +6,7 @@ use Open311; has bodies => ( is => 'ro' ); has found_contacts => ( is => 'rw', default => sub { [] } ); has verbose => ( is => 'ro', default => 0 ); -has schema => ( is => 'ro', lazy => 1, default => sub { FixMyStreet::DB->connect } ); +has schema => ( is => 'ro', lazy => 1, default => sub { FixMyStreet::DB->schema->connect } ); has _current_body => ( is => 'rw' ); has _current_open311 => ( is => 'rw' ); @@ -131,14 +131,13 @@ sub _handle_existing_contact { print $self->_current_body->id . " already has a contact for service code " . $self->_current_service->{service_code} . "\n" if $self->verbose >= 2; - if ( $contact->deleted || $service_name ne $contact->category || $self->_current_service->{service_code} ne $contact->email ) { + if ( $contact->state eq 'deleted' || $service_name ne $contact->category || $self->_current_service->{service_code} ne $contact->email ) { eval { $contact->update( { category => $service_name, email => $self->_current_service->{service_code}, - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'automatically undeleted by script', @@ -175,8 +174,7 @@ sub _create_contact { email => $self->_current_service->{service_code}, body_id => $self->_current_body->id, category => $service_name, - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => $0, whenedited => \'current_timestamp', note => 'created automatically by script', @@ -278,11 +276,10 @@ sub _normalize_service_name { sub _delete_contacts_not_in_service_list { my $self = shift; - my $found_contacts = $self->schema->resultset('Contact')->search( + my $found_contacts = $self->schema->resultset('Contact')->not_deleted->search( { email => { -not_in => $self->found_contacts }, body_id => $self->_current_body->id, - deleted => 0, } ); @@ -299,7 +296,7 @@ sub _delete_contacts_not_in_service_list { $found_contacts->update( { - deleted => 1, + state => 'deleted', editor => $0, whenedited => \'current_timestamp', note => 'automatically marked as deleted by script' |