aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-08 13:49:40 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-08 13:49:40 +0100
commit0cd38fb6150d66892fb249ab4906df3cbc5bebb7 (patch)
treee83f67c43f4ede6a3f52efe7a034577fa65ddc77
parent485f739aad7371a0739b42dfb165f9f24882c107 (diff)
option to only send problem details over open311 for Bromley
-rw-r--r--perllib/FixMyStreet/SendReport/Open311.pm7
-rw-r--r--perllib/Open311.pm12
-rw-r--r--t/open311.t24
3 files changed, 39 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm
index e572a76e5..fe99e3043 100644
--- a/perllib/FixMyStreet/SendReport/Open311.pm
+++ b/perllib/FixMyStreet/SendReport/Open311.pm
@@ -31,6 +31,9 @@ sub send {
my $conf = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $council, endpoint => { '!=', '' } } )->first;
my $always_send_latlong = 1;
+
+ my $basic_desc = 0;
+
# Extra bromley fields
if ( $row->council =~ /2482/ ) {
@@ -45,7 +48,10 @@ sub send {
push @$extra, { name => 'requested_datetime', value => DateTime::Format::W3CDTF->format_datetime($row->confirmed_local->set_nanosecond(0)) };
push @$extra, { name => 'email', value => $row->user->email };
$row->extra( $extra );
+
$always_send_latlong = 0;
+
+ $basic_desc = 1;
}
# FIXME: we've already looked this up before
@@ -60,6 +66,7 @@ sub send {
endpoint => $conf->endpoint,
api_key => $conf->api_key,
always_send_latlong => $always_send_latlong,
+ basic_description => $basic_desc,
);
# non standard west berks end points
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index 47baed082..b380409cf 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 basic_description => ( is => 'ro', isa => 'Bool', default => 0 );
before [
qw/get_service_list get_service_meta_info get_service_requests get_service_request_updates
@@ -82,9 +83,14 @@ sub _populate_service_request_params {
my $extra = shift;
my $service_code = shift;
- my $description = $self->_generate_service_request_description(
- $problem, $extra
- );
+ my $description;
+ if ( $self->basic_description ) {
+ $description = $problem->detail;
+ } else {
+ $description = $self->_generate_service_request_description(
+ $problem, $extra
+ );
+ }
my ( $firstname, $lastname ) = ( $problem->user->name =~ /(\w+)\s+(.+)/ );
diff --git a/t/open311.t b/t/open311.t
index c937d4844..d6a5ef6f6 100644
--- a/t/open311.t
+++ b/t/open311.t
@@ -91,10 +91,32 @@ EOT
is $c->param('last_name'), 'User', 'correct last name';
is $c->param('lat'), 1, 'latitide correct';
is $c->param('long'), 2, 'longitude correct';
- is $c->param('description'), $description, 'descritpion correct';
+ is $c->param('description'), $description, 'description correct';
is $c->param('service_code'), 'pothole', 'service code correct';
};
+subtest 'posting service request with basic_description' => sub {
+ my $extra = {
+ url => 'http://example.com/report/1',
+ };
+
+ my $results = make_service_req(
+ $problem,
+ $extra,
+ $problem->category,
+ '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>',
+ { basic_description => 1 },
+ );
+
+ is $results->{ res }, 248, 'got request id';
+
+ my $req = $o->test_req_used;
+
+ my $c = CGI::Simple->new( $results->{ req }->content );
+
+ is $c->param('description'), $problem->detail, 'description correct';
+};
+
for my $test (
{
desc => 'extra values in service request',