diff options
Diffstat (limited to 'perllib/FixMyStreet/SendReport/Open311.pm')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Open311.pm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index 8d7a418af..27b65137e 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -9,6 +9,9 @@ use FixMyStreet::App; use mySociety::Config; use DateTime::Format::W3CDTF; use Open311; +use Readonly; + +Readonly::Scalar my $COUNCIL_ID_OXFORDSHIRE => 2237; sub should_skip { my $self = shift; @@ -67,6 +70,17 @@ sub send { $basic_desc = 1; } + # extra Oxfordshire fields: send northing and easting, and the FMS id + if ( $row->council =~ /$COUNCIL_ID_OXFORDSHIRE/ ) { + my $extra = $row->extra; + push @$extra, { name => 'external_id', value => $row->id }; + if ( $row->used_map || ( !$row->used_map && !$row->postcode ) ) { + push @$extra, { name => 'northing', value => $h->{northing} }; + push @$extra, { name => 'easting', value => $h->{easting} }; + } + $row->extra( $extra ); + } + # FIXME: we've already looked this up before my $contact = FixMyStreet::App->model("DB::Contact")->find( { deleted => 0, @@ -89,20 +103,25 @@ sub send { $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' } ); + } + # required to get round issues with CRM constraints if ( $row->council =~ /2218/ ) { $row->user->name( $row->user->id . ' ' . $row->user->name ); } if ($row->cobrand eq 'fixmybarangay') { - # FixMyBarangay endpoints expect external_id as an attribute + # FixMyBarangay endpoints expect external_id as an attribute, as do Oxfordshire $row->extra( [ { 'name' => 'external_id', 'value' => $row->id } ] ); } my $resp = $open311->send_service_request( $row, $h, $contact->email ); # make sure we don't save user changes from above - if ( $row->council =~ /2218/ || $row->council =~ /2482/ || $row->cobrand eq 'fixmybarangay') { + if ( $row->council =~ /(2218|2482|$COUNCIL_ID_OXFORDSHIRE)/ || $row->cobrand eq 'fixmybarangay') { $row->discard_changes(); } |