aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Bexley.pm27
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm10
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Contact.pm9
-rw-r--r--t/app/controller/report_new_open311.t1
-rw-r--r--t/cobrand/bexley.t10
7 files changed, 58 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89f215660..b16fa561d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,6 +35,7 @@
- Add new upload_files flag which sends files/photos as part of the
POST service request.
- Allow description in email template with placeholder.
+ - Do not store display-only extra fields on new reports.
* v2.6 (3rd May 2019)
- New features:
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 7822f5cf3..2246f6aea 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1077,7 +1077,7 @@ sub set_report_extras : Private {
my ($self, $c, $contacts, $param_prefix) = @_;
$param_prefix ||= "";
- my @metalist = map { [ $_->get_metadata_for_input, $param_prefix ] } @$contacts;
+ my @metalist = map { [ $_->get_metadata_for_storage, $param_prefix ] } @$contacts;
push @metalist, map { [ $_->get_extra_fields, "extra[" . $_->id . "]" ] } @{$c->stash->{report_extra_fields}};
my @extra;
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm
index 1f16b817e..26470617a 100644
--- a/perllib/FixMyStreet/Cobrand/Bexley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bexley.pm
@@ -131,4 +131,31 @@ sub open311_post_send {
$sender->send($row, $h);
}
+sub dashboard_export_problems_add_columns {
+ my $self = shift;
+ my $c = $self->{c};
+
+ my %groups;
+ if ($c->stash->{body}) {
+ %groups = FixMyStreet::DB->resultset('Contact')->active->search({
+ body_id => $c->stash->{body}->id,
+ })->group_lookup;
+ }
+
+ splice @{$c->stash->{csv}->{headers}}, 5, 0, 'Subcategory';
+ splice @{$c->stash->{csv}->{columns}}, 5, 0, 'subcategory';
+
+ $c->stash->{csv}->{extra_data} = sub {
+ my $report = shift;
+
+ if ($groups{$report->category}) {
+ return {
+ category => $groups{$report->category},
+ subcategory => $report->category,
+ };
+ }
+ return {};
+ };
+}
+
1;
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index 17620f279..3ce0ec66f 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -121,6 +121,16 @@ sub get_metadata_for_input {
return \@metadata;
}
+sub get_metadata_for_storage {
+ my $self = shift;
+ my $metadata = $self->get_metadata_for_input;
+
+ # Also ignore any that were only for textual display
+ my @metadata = grep { ($_->{variable} || '') ne 'false' } @$metadata;
+
+ return \@metadata;
+}
+
sub id_field {
my $self = shift;
return $self->get_extra_metadata('id_field') || 'fixmystreet_id';
diff --git a/perllib/FixMyStreet/DB/ResultSet/Contact.pm b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
index 8ef6d1ac5..7b3258262 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Contact.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
@@ -37,4 +37,13 @@ sub summary_count {
);
}
+sub group_lookup {
+ my $rs = shift;
+ map {
+ my $group = $_->get_extra_metadata('group') || '';
+ $group = join(',', ref $group ? @$group : $group);
+ $_->category => $group
+ } $rs->all;
+}
+
1;
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index dc9a26791..d2f39f40f 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -45,6 +45,7 @@ $mech->create_contact_ok(
category => 'Ball lighting',
email => '102',
extra => { _fields => [
+ { description => 'Message', code => 'message', required => 'false', variable => 'false', order => '0' },
{ description => 'Size', code => 'size', required => 'True', automated => '' },
{ description => 'Speed', code => 'speed', required => 'True', automated => 'server_set' },
{ description => 'Colour', code => 'colour', required => 'True', automated => 'hidden_field' },
diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t
index f72b7e7c4..f227e7450 100644
--- a/t/cobrand/bexley.t
+++ b/t/cobrand/bexley.t
@@ -33,7 +33,9 @@ $mech->create_contact_ok(body_id => $body->id, category => 'Abandoned and untaxe
$mech->create_contact_ok(body_id => $body->id, category => 'Lamp post', email => "LAMP");
$mech->create_contact_ok(body_id => $body->id, category => 'Parks and open spaces', email => "PARK");
$mech->create_contact_ok(body_id => $body->id, category => 'Dead animal', email => "ANIM");
-$mech->create_contact_ok(body_id => $body->id, category => 'Something dangerous', email => "DANG");
+my $category = $mech->create_contact_ok(body_id => $body->id, category => 'Something dangerous', email => "DANG");
+$category->set_extra_metadata(group => 'Danger things');
+$category->update;
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'bexley' ],
@@ -119,6 +121,12 @@ FixMyStreet::override_config {
$mech->content_lacks('Resend report');
};
+ subtest 'extra CSV column present' => sub {
+ $mech->get_ok('/dashboard?export=1');
+ $mech->content_contains(',Category,Subcategory,');
+ $mech->content_contains('"Danger things","Something dangerous"');
+ };
+
};
subtest 'nearest road returns correct road' => sub {