aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2020-02-05 15:04:07 +0000
committerM Somerville <matthew-github@dracos.co.uk>2020-08-10 17:43:57 +0100
commitcb257d9b2f4dcb9c9fa54836e6e08378194ff393 (patch)
treef65789e3c55fc2cdd4748f82731a078dfb5442ba
parenta86acd036ad52a15ee3cf546f7f496f212be3cf5 (diff)
[Oxfordshire] Add NSG roads layer.
Prevent reports on areas not on a road for relevant categories, and do not allow reporting on private roads.
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm5
-rw-r--r--t/cobrand/oxfordshire.t60
-rw-r--r--templates/web/oxfordshire/report/new/roads_message.html7
-rw-r--r--web/cobrands/oxfordshire/assets.js50
4 files changed, 99 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index cf88495f8..6021827cb 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -147,6 +147,11 @@ sub open311_pre_send {
my $text = $row->detail . "\n\nAsset Id: $fid\n";
$row->detail($text);
}
+
+ if (my $usrn = $row->get_extra_field_value('usrn')) {
+ my $text = $row->detail . "\n\nUSRN: $usrn\n";
+ $row->detail($text);
+ }
}
sub open311_post_send {
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index 16b7e5714..5207ba916 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -141,33 +141,47 @@ FixMyStreet::override_config {
my $contact = $mech->create_contact_ok( body_id => $oxon->id, category => 'Gullies and Catchpits', email => 'GC' );
$contact->set_extra_fields( (
{ code => 'feature_id', datatype => 'hidden', variable => 'true' },
+ { code => 'usrn', datatype => 'hidden', variable => 'true' },
) );
$contact->update;
FixMyStreet::Script::Reports::send(); # Make sure no waiting reports
- subtest 'Check special Open311 request handling', sub {
- my ($p) = $mech->create_problems_for_body( 1, $oxon->id, 'Test', {
- cobrand => 'oxfordshire',
- category => 'Gullies and Catchpits',
- user => $user,
- latitude => 51.754926,
- longitude => -1.256179,
- });
- $p->set_extra_fields({ name => 'feature_id', value => 9875432});
- $p->update;
-
- my $test_data = FixMyStreet::Script::Reports::send();
-
- $p->discard_changes;
- ok $p->whensent, 'Report marked as sent';
- is $p->send_method_used, 'Open311', 'Report sent via Open311';
- is $p->external_id, 248, 'Report has right external ID';
- unlike $p->detail, qr/Asset Id:/, 'asset id not saved to report detail';
-
- my $req = $test_data->{test_req_used};
- my $c = CGI::Simple->new($req->content);
- like $c->param('description'), qr/Asset Id: 9875432/, 'asset id included in body';
- };
+ for my $test (
+ {
+ field => 'usrn',
+ value => '12345',
+ text => 'USRN',
+ },
+ {
+ field => 'feature_id',
+ value => '12345',
+ text => 'Asset Id',
+ },
+ ) {
+ subtest 'Check special Open311 request handling of ' . $test->{text}, sub {
+ my ($p) = $mech->create_problems_for_body( 1, $oxon->id, 'Test', {
+ cobrand => 'oxfordshire',
+ category => 'Gullies and Catchpits',
+ user => $user,
+ latitude => 51.754926,
+ longitude => -1.256179,
+ });
+ $p->set_extra_fields({ name => $test->{field}, value => $test->{value}});
+ $p->update;
+
+ my $test_data = FixMyStreet::Script::Reports::send();
+
+ $p->discard_changes;
+ ok $p->whensent, 'Report marked as sent';
+ is $p->send_method_used, 'Open311', 'Report sent via Open311';
+ is $p->external_id, 248, 'Report has right external ID';
+ unlike $p->detail, qr/$test->{text}:/, $test->{text} . ' not saved to report detail';
+
+ my $req = $test_data->{test_req_used};
+ my $c = CGI::Simple->new($req->content);
+ like $c->param('description'), qr/$test->{text}: $test->{value}/, $test->{text} . ' included in body';
+ };
+ }
};
diff --git a/templates/web/oxfordshire/report/new/roads_message.html b/templates/web/oxfordshire/report/new/roads_message.html
new file mode 100644
index 000000000..1c1dd66b0
--- /dev/null
+++ b/templates/web/oxfordshire/report/new/roads_message.html
@@ -0,0 +1,7 @@
+<div id="js-roads-responsibility" class="box-warning hidden">
+ <div id="js-not-a-road" class="hidden js-responsibility-message">
+ <p>This area is not under the responsibility of Oxfordshire
+ County Council and therefore we are unable to accept reports in
+ this area / street.</p>
+ </div>
+</div>
diff --git a/web/cobrands/oxfordshire/assets.js b/web/cobrands/oxfordshire/assets.js
index 9bd38acac..1f7a7808d 100644
--- a/web/cobrands/oxfordshire/assets.js
+++ b/web/cobrands/oxfordshire/assets.js
@@ -135,4 +135,54 @@ fixmystreet.assets.add(owned_defaults, {
asset_item: 'grit bin'
});
+var road_occ_maintainable = 'Maintainable at Public Expense';
+
+function road_owned(f) {
+ return f &&
+ f.attributes &&
+ f.attributes.STREET_MAINTENANCE_RESPONSIBILITY_NAME &&
+ f.attributes.STREET_MAINTENANCE_RESPONSIBILITY_NAME.lastIndexOf(road_occ_maintainable, 0) === 0;
+}
+
+fixmystreet.assets.add(defaults, {
+ stylemap: fixmystreet.assets.stylemap_invisible,
+ wfs_url: proxy_base_url + 'nsg/',
+ wfs_feature: "WFS_STREETS_CLASSIFIED_ROADS_INTERESTS",
+ propertyNames: ['TYPE1_2_USRN', 'STREET_MAINTENANCE_RESPONSIBILITY_NAME', 'SHAPE_GEOMETRY'],
+ srsName: "EPSG:27700",
+ geometryName: null,
+ usrn: {
+ attribute: 'TYPE1_2_USRN',
+ field: 'usrn'
+ },
+ non_interactive: true,
+ road: true,
+ no_asset_msg_id: '#js-not-a-road',
+ asset_item: 'road',
+ asset_type: 'road',
+ actions: {
+ found: function(layer, feature) {
+ fixmystreet.message_controller.road_found(layer, feature, road_owned, '#js-not-a-road');
+ },
+ not_found: fixmystreet.message_controller.road_not_found
+ },
+ asset_category: [
+ "Bridges",
+ "Carriageway Defect",
+ "Current Roadworks",
+ "Drainage",
+ "Gully and Catchpits",
+ "Highway Schemes",
+ "Ice/Snow",
+ "Manhole",
+ "Pavements",
+ "Pothole",
+ "Road Traffic Signs and Road Markings",
+ "Roads/highways",
+ "Street lighting",
+ "Traffic Lights (permanent only)",
+ "Trees"
+ ]
+});
+
})();