aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport/Open311.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Open311.pm')
-rw-r--r--perllib/FixMyStreet/SendReport/Open311.pm26
1 files changed, 16 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm
index 93b96ce00..1b79bcc99 100644
--- a/perllib/FixMyStreet/SendReport/Open311.pm
+++ b/perllib/FixMyStreet/SendReport/Open311.pm
@@ -30,8 +30,8 @@ sub send {
my $result = -1;
- foreach my $council ( keys %{ $self->councils } ) {
- my $conf = $self->councils->{$council}->{config};
+ foreach my $body ( @{ $self->bodies } ) {
+ my $conf = $self->body_config->{ $body->id };
my $always_send_latlong = 1;
my $send_notpinpointed = 0;
@@ -39,8 +39,13 @@ sub send {
my $extended_desc = 1;
+ # To rollback temporary changes made by this function
+ my $revert = 0;
+
# Extra bromley fields
- if ( $row->council =~ /2482/ ) {
+ if ( $row->bodies_str == 2482 ) {
+
+ $revert = 1;
my $extra = $row->extra;
if ( $row->used_map || ( !$row->used_map && !$row->postcode ) ) {
@@ -88,7 +93,7 @@ sub send {
# FIXME: we've already looked this up before
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
- area_id => $conf->area_id,
+ body_id => $body->id,
category => $row->category
} );
@@ -103,31 +108,32 @@ sub send {
);
# non standard west berks end points
- if ( $row->council =~ /2619/ ) {
+ if ( $row->bodies_str =~ /2619/ ) {
$open311->endpoints( { services => 'Services', requests => 'Requests' } );
}
# non-standard Oxfordshire endpoint (because it's just a script, not a full Open311 service)
if ( $row->council =~ /$COUNCIL_ID_OXFORDSHIRE/ ) {
$open311->endpoints( { requests => 'open311_service_request.cgi' } );
+ $revert = 1;
}
# required to get round issues with CRM constraints
- if ( $row->council =~ /2218/ ) {
+ if ( $row->bodies_str =~ /2218/ ) {
$row->user->name( $row->user->id . ' ' . $row->user->name );
+ $revert = 1;
}
if ($row->cobrand eq 'fixmybarangay') {
# FixMyBarangay endpoints expect external_id as an attribute, as do Oxfordshire
$row->extra( [ { 'name' => 'external_id', 'value' => $row->id } ] );
+ $revert = 1;
}
my $resp = $open311->send_service_request( $row, $h, $contact->email );
# make sure we don't save user changes from above
- if ( $row->council =~ /(2218|2482|$COUNCIL_ID_OXFORDSHIRE)/ || $row->cobrand eq 'fixmybarangay') {
- $row->discard_changes();
- }
+ $row->discard_changes() if $revert;
if ( $resp ) {
$row->external_id( $resp );
@@ -150,7 +156,7 @@ sub send {
} else {
$result *= 1;
# temporary fix to resolve some issues with west berks
- if ( $row->council =~ /2619/ ) {
+ if ( $row->bodies_str =~ /2619/ ) {
$result *= 0;
}
}