aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-23 10:53:04 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-23 10:53:04 +0100
commit6f00ea0f96c25d81adf7e9e68a0228d193eb45d0 (patch)
tree7585e3d1af811fd7bb7b2b137bd522303fd95b29
parent37887356e600137090aa9819816d659be19ce11c (diff)
send address_id with NOTPINPOINTED to Bromley if not used map and no postcode
-rw-r--r--perllib/FixMyStreet/SendReport/Open311.pm9
-rw-r--r--perllib/Open311.pm11
-rw-r--r--t/open311.t18
3 files changed, 33 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm
index fe99e3043..845a6295c 100644
--- a/perllib/FixMyStreet/SendReport/Open311.pm
+++ b/perllib/FixMyStreet/SendReport/Open311.pm
@@ -31,6 +31,7 @@ sub send {
my $conf = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $council, endpoint => { '!=', '' } } )->first;
my $always_send_latlong = 1;
+ my $send_notpinpointed = 0;
my $basic_desc = 0;
@@ -38,8 +39,10 @@ sub send {
if ( $row->council =~ /2482/ ) {
my $extra = $row->extra;
- push @$extra, { name => 'northing', value => $h->{northing} };
- push @$extra, { name => 'easting', value => $h->{easting} };
+ if ( $row->used_map || ( !$row->used_map && !$row->postcode ) ) {
+ push @$extra, { name => 'northing', value => $h->{northing} };
+ push @$extra, { name => 'easting', value => $h->{easting} };
+ }
push @$extra, { name => 'report_url', value => $h->{url} };
push @$extra, { name => 'service_request_id_ext', value => $row->id };
push @$extra, { name => 'report_title', value => $row->title };
@@ -50,6 +53,7 @@ sub send {
$row->extra( $extra );
$always_send_latlong = 0;
+ $send_notpinpointed = 1;
$basic_desc = 1;
}
@@ -66,6 +70,7 @@ sub send {
endpoint => $conf->endpoint,
api_key => $conf->api_key,
always_send_latlong => $always_send_latlong,
+ send_notpinpointed => $send_notpinpointed,
basic_description => $basic_desc,
);
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index 730b71958..0d3c0720d 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -21,6 +21,7 @@ has debug_details => ( is => 'rw', 'isa' => 'Str', default => '' );
has success => ( is => 'rw', 'isa' => 'Bool', default => 0 );
has error => ( is => 'rw', 'isa' => 'Str', default => '' );
has always_send_latlong => ( is => 'ro', isa => 'Bool', default => 1 );
+has send_notpinpointed => ( is => 'ro', isa => 'Bool', default => 0 );
has basic_description => ( is => 'ro', isa => 'Bool', default => 0 );
before [
@@ -105,10 +106,18 @@ sub _populate_service_request_params {
# if you click nearby reports > skip map then it's possible
# to end up with used_map = f and nothing in postcode
if ( $problem->used_map || $self->always_send_latlong
- || ( !$problem->used_map && !$problem->postcode ) )
+ || ( !$self->send_notpinpointed && !$problem->used_map
+ && !$problem->postcode ) )
{
$params->{lat} = $problem->latitude;
$params->{long} = $problem->longitude;
+ # this is a special case for sending to Bromley so they can
+ # report accuracy levels correctly. We include easting and
+ # northing as attributes elsewhere.
+ } elsif ( $self->send_notpinpointed && !$problem->used_map
+ && !$problem->postcode )
+ {
+ $params->{address_id} = '#NOTPINPOINTED#';
} else {
$params->{address_string} = $problem->postcode;
}
diff --git a/t/open311.t b/t/open311.t
index 358a58a44..60757219e 100644
--- a/t/open311.t
+++ b/t/open311.t
@@ -349,6 +349,14 @@ for my $test (
postcode => '',
used_map => 0,
includes_latlong => 1,
+ },
+ {
+ desc => 'no use lat long, no map and no postcode sends lat long',
+ use_latlong => 0,
+ notpinpoint => 1,
+ postcode => '',
+ used_map => 0,
+ includes_latlong => 0,
}
) {
subtest $test->{desc} => sub {
@@ -361,14 +369,20 @@ for my $test (
$extra,
$problem->category,
'<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>',
- { always_send_latlong => $test->{use_latlong} },
+ { always_send_latlong => $test->{use_latlong},
+ send_notpinpointed => $test->{notpinpoint} },
);
is $results->{ res }, 248, 'got request id';
my $c = CGI::Simple->new( $results->{ req }->content );
- if ( $test->{includes_latlong} ) {
+ if ( $test->{notpinpoint} ) {
+ is $c->param('lat'), undef, 'no latitude';
+ is $c->param('long'), undef, 'no longitude';
+ is $c->param('address_string'), undef, 'no address';
+ is $c->param('address_id'), '#NOTPINPOINTED#', 'has not pinpointed';
+ } elsif ( $test->{includes_latlong} ) {
ok $c->param('lat'), 'has latitude';
ok $c->param('long'), 'has longitude';
is $c->param('address_string'), undef, 'no address';