aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm63
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm3
-rw-r--r--perllib/FixMyStreet/SendReport/Open311.pm23
3 files changed, 86 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
new file mode 100644
index 000000000..578dfa53c
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -0,0 +1,63 @@
+package FixMyStreet::Cobrand::Oxfordshire;
+use base 'FixMyStreet::Cobrand::UKCouncils';
+
+use strict;
+use warnings;
+
+sub council_id { return 2237; }
+sub council_area { return 'Oxfordshire'; }
+sub council_name { return 'Oxfordshire County Council'; }
+sub council_url { return 'oxfordshire'; }
+
+sub base_url {
+ return FixMyStreet->config('BASE_URL') if FixMyStreet->config('STAGING_SITE');
+ return 'http://fixmystreet.oxfordshire.gov.uk';
+}
+
+# Different to councils parent due to this being a two-tier council. If we get
+# more, this can be genericised in the parent.
+sub problems_clause {
+ return { council => { like => '%2237%' } };
+}
+
+sub path_to_web_templates {
+ my $self = shift;
+ return [
+ FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
+ FixMyStreet->path_to( 'templates/web/fixmystreet' )->stringify
+ ];
+}
+
+sub enter_postcode_text {
+ my ($self) = @_;
+ return 'Enter an Oxfordshire postcode, or street name and area';
+}
+
+sub disambiguate_location {
+ my $self = shift;
+ my $string = shift;
+ return {
+ %{ $self->SUPER::disambiguate_location() },
+ centre => '51.765765,-1.322324',
+ span => '0.154963,0.24347', # NB span is not correct
+ bounds => [ 51.459413, -1.719500, 52.168471, -0.870066 ],
+ };
+}
+
+sub example_places {
+ return ( 'OX20 1SZ', 'Park St, Woodstock' );
+}
+
+# If we ever link to a district problem report, needs to be to main FixMyStreet
+sub base_url_for_report {
+ my ( $self, $report ) = @_;
+ my %councils = map { $_ => 1 } @{$report->councils};
+ if ( $councils{2237} ) {
+ return $self->base_url;
+ } else {
+ return FixMyStreet->config('BASE_URL');
+ }
+}
+
+1;
+
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index ce197076b..feca81d43 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -581,7 +581,8 @@ sub body {
# Note: this only makes sense when called on a problem that has been sent!
sub can_display_external_id {
my $self = shift;
- if ($self->external_id && $self->send_method_used && $self->send_method_used eq 'barnet') {
+ if ($self->external_id && $self->send_method_used &&
+ ($self->send_method_used eq 'barnet' || $self->cobrand eq 'oxfordshire')) {
return 1;
}
return 0;
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();
}