aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/EastSussex.pm41
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm15
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm2
-rw-r--r--t/cobrand/oxfordshire.t29
-rw-r--r--templates/web/fixmystreet.com/footer_extra_js.html1
-rw-r--r--web/cobrands/eastsussex/assets.js139
7 files changed, 227 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/Cobrand/EastSussex.pm b/perllib/FixMyStreet/Cobrand/EastSussex.pm
new file mode 100644
index 000000000..c113a0986
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/EastSussex.pm
@@ -0,0 +1,41 @@
+package FixMyStreet::Cobrand::EastSussex;
+use parent 'FixMyStreet::Cobrand::UK';
+
+use strict;
+use warnings;
+
+sub council_area_id { return 2224; }
+
+sub open311_pre_send {
+ my ($self, $row, $open311) = @_;
+
+ my $contact = $row->category_row;
+ my $fields = $contact->get_extra_fields;
+ for my $field ( @$fields ) {
+ if ($field->{variable} && !$field->{automated}) {
+ my $text = $row->detail;
+ my $q = $row->get_extra_field_value( $field->{code} ) || '';
+ $text .= "\n\n" . $field->{description} . "\n" . $q;
+ $row->detail($text);
+ }
+ }
+}
+
+sub open311_post_send {
+ my ($self, $row, $h, $contact) = @_;
+
+ my $fields = $contact->get_extra_fields;
+ my $text = $row->detail;
+ my $added = '';
+ for my $field ( @$fields ) {
+ if ($field->{variable} && !$field->{automated}) {
+ my $q = $row->get_extra_field_value( $field->{code} ) || '';
+ $added .= "\n\n" . $field->{description} . "\n" . $q;
+ }
+ }
+
+ $text =~ s/\Q$added\E//;
+ $row->detail($text);
+}
+
+1;
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index d81ecea74..b110731e6 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -202,4 +202,19 @@ sub available_permissions {
return $perms;
}
+sub dashboard_export_problems_add_columns {
+ my $self = shift;
+ my $c = $self->{c};
+
+ push @{$c->stash->{csv}->{headers}}, "HIAMS Ref";
+ push @{$c->stash->{csv}->{columns}}, "customer_reference";
+
+ $c->stash->{csv}->{extra_data} = sub {
+ my $ref = shift->get_extra_metadata('customer_reference') || '';
+ return {
+ customer_reference => $ref,
+ };
+ };
+}
+
1;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 489c43090..37563d327 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -800,7 +800,7 @@ sub defect_types {
# 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->to_body_named('Oxfordshire|Lincolnshire|Isle of Wight')) {
+ if ($self->external_id && $self->to_body_named('Oxfordshire|Lincolnshire|Isle of Wight|East Sussex')) {
return 1;
}
return 0;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 3e48170d8..359d5224a 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -159,7 +159,7 @@ sub _recent {
$probs = [ $rs->search({
id => [ map { $_->id } @$probs ],
%$query,
- })->all ];
+ }, $attrs)->all ];
} else {
$probs = [ $rs->search( $query, $attrs )->all ];
Memcached::set($key, $probs, _cache_timeout());
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index dd5eedc8d..907c66c19 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -5,6 +5,7 @@ use FixMyStreet::Script::Alerts;
my $mech = FixMyStreet::TestMech->new;
my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council');
+my $counciluser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxon);
subtest 'check /around?ajax defaults to open reports only' => sub {
my $categories = [ 'Bridges', 'Fences', 'Manhole' ];
@@ -105,6 +106,34 @@ subtest 'check unable to fix label' => sub {
};
};
+subtest 'extra CSV columns are present' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+
+ $mech->log_in_ok( $counciluser->email );
+
+ $mech->get_ok('/dashboard?export=1');
+
+ my @rows = $mech->content_as_csv;
+ is scalar @rows, 7, '1 (header) + 6 (reports) = 7 lines';
+ is scalar @{$rows[0]}, 21, '21 columns present';
+
+ is_deeply $rows[0],
+ [
+ 'Report ID', 'Title', 'Detail', 'User Name', 'Category',
+ 'Created', 'Confirmed', 'Acknowledged', 'Fixed', 'Closed',
+ 'Status', 'Latitude', 'Longitude', 'Query', 'Ward',
+ 'Easting', 'Northing', 'Report URL', 'Site Used',
+ 'Reported As', 'HIAMS Ref',
+ ],
+ 'Column headers look correct';
+
+ is $rows[1]->[20], 'ENQ12456', 'HIAMS reference included in row';
+ };
+};
+
END {
done_testing();
}
diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html
index d2fe1e588..289e230e7 100644
--- a/templates/web/fixmystreet.com/footer_extra_js.html
+++ b/templates/web/fixmystreet.com/footer_extra_js.html
@@ -11,6 +11,7 @@ IF bodyclass.match('mappage');
scripts.push( version('/cobrands/bromley/assets.js') );
scripts.push( version('/cobrands/buckinghamshire/assets.js') );
scripts.push( version('/cobrands/cheshireeast/assets.js') );
+ scripts.push( version('/cobrands/eastsussex/assets.js') );
scripts.push( version('/cobrands/isleofwight/assets.js') );
scripts.push( version('/cobrands/lincolnshire/assets.js') );
scripts.push( version('/cobrands/northamptonshire/assets.js') );
diff --git a/web/cobrands/eastsussex/assets.js b/web/cobrands/eastsussex/assets.js
new file mode 100644
index 000000000..296c8ede4
--- /dev/null
+++ b/web/cobrands/eastsussex/assets.js
@@ -0,0 +1,139 @@
+(function(){
+
+if (!fixmystreet.maps) {
+ return;
+}
+
+
+OpenLayers.Format.EastSussex = OpenLayers.Class(OpenLayers.Format.JSON, {
+ read: function(json, type, filter) {
+ var obj = json;
+ if (typeof json == "string") {
+ obj = OpenLayers.Format.JSON.prototype.read.apply(this,
+ [json, filter]);
+ }
+
+ var results = [];
+ for (var i=0, len=obj.length; i<len; i++) {
+ var item = obj[i];
+ var geom = new OpenLayers.Geometry.Point(item.Mid_Location__c.longitude, item.Mid_Location__c.latitude);
+ var vec = new OpenLayers.Feature.Vector(geom, item);
+ results.push(vec);
+ }
+
+ return results;
+ },
+ CLASS_NAME: "OpenLayers.Format.EastSussex"
+});
+
+OpenLayers.Protocol.EastSussex = OpenLayers.Class(OpenLayers.Protocol.HTTP, {
+ read: function(options) {
+ OpenLayers.Protocol.prototype.read.apply(this, arguments);
+ options = options || {};
+ options.params = OpenLayers.Util.applyDefaults(
+ options.params, this.options.params);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
+ var types = options.types.join('&types=');
+ var coords = fixmystreet.map.getCenterWGS84();
+ options.url = options.url + '?longitude=' + coords.lat + '&latitude=' + coords.lon + '&types=' + types;
+ var resp = new OpenLayers.Protocol.Response({requestType: "read"});
+ resp.priv = OpenLayers.Request.GET({
+ url: options.url,
+ callback: this.createCallback(this.handleRead, resp, options),
+ params: options.params,
+ headers: options.headers
+ });
+ },
+ CLASS_NAME: "OpenLayers.Protocol.EastSussex"
+});
+
+var defaults = {
+ http_options: {
+ url: fixmystreet.staging ? "https://tilma.staging.mysociety.org/proxy/escc/" : "https://tilma.mysociety.org/proxy/escc/"
+ },
+ max_resolution: 1.194328566789627,
+ geometryName: 'msGeometry',
+ srsName: "EPSG:4326",
+ body: "East Sussex County Council",
+ format_class: OpenLayers.Format.EastSussex,
+ protocol_class: OpenLayers.Protocol.EastSussex,
+ asset_id_field: 'asset_id',
+ attributes: {
+ asset_id: 'id'
+ }
+};
+
+fixmystreet.assets.add(defaults, {
+ http_options: {
+ types: [
+ "Bollard", "Central Refuge Beacon", "External Illuminated Sign", "Floodlight", "Internal Illuminated Sign", "Lighting Column", "Reflect Bollard", "Safety bollards", "Solar Bollard", "Subway Unit", "Zebra X Beacon"
+ ]
+ },
+ asset_item: 'street light',
+ asset_category: ["Burning By Day", "Intermittent", "Lamp Dim", "Lamp Flashing", "Lamp Obscured", "Lamp Out", "Missing Number", "Noisy Column", "Vandalism" ],
+ select_action: true,
+ actions: {
+ asset_found: function(asset) {
+ var id = asset.attributes.Name || '';
+ if (id !== '') {
+ $('.category_meta_message').html('You have selected <b>' + id + '</b>');
+ } else {
+ $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
+ }
+ },
+ asset_not_found: function() {
+ $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
+ }
+ }
+});
+
+fixmystreet.assets.add(defaults, {
+ http_options: {
+ types: [
+ "Grit bin"
+ ]
+ },
+ asset_item: 'grit bin',
+ asset_category: ["Broken Grit Bin", "Request For New Grit Bin", "Request To Refill Grit Bin"]
+});
+
+fixmystreet.assets.add(defaults, {
+ http_options: {
+ types: [
+ "Filter Drain", "Gully and Catchpit"
+ ]
+ },
+ asset_item: 'drain',
+ asset_category: ["Blocked Drain", "Culvert", "Broken Drain Cover", "Smell", "Sunken Drain", "Missing Drain Cover"],
+ select_action: true,
+ actions: {
+ asset_found: function(asset) {
+ var last_clean = asset.attributes.Gully_Last_Clean_Date__c || '';
+ var next_clean = asset.attributes.Gully_Next_Clean_Date__c || '';
+ if (last_clean !== '' || next_clean !== '') {
+ var message = '';
+ if (last_clean) { message += '<b>Last Cleaned</b>: ' + last_clean; }
+ if (next_clean) { message += ' <b>Next Clean</b>: ' + next_clean; }
+ $('.category_meta_message').html(message);
+ } else {
+ $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
+ }
+ },
+ asset_not_found: function() {
+ $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map &raquo;');
+ }
+ }
+});
+
+// can have multiple group
+$(function(){
+ $("#problem_form").on("change.category", function() {
+ var group = '';
+ if (OpenLayers.Util.indexOf(fixmystreet.bodies, 'East Sussex County Council') != -1 ) {
+ group = $('#form_category :selected').parent().attr('label');
+ }
+ $('#form_group').val(group);
+ });
+});
+
+})();