aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm33
-rw-r--r--perllib/FixMyStreet/TestMech.pm11
2 files changed, 44 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index 095e80604..5e9316709 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -197,6 +197,39 @@ sub default_map_zoom { 3 }
sub enable_category_groups { 1 }
+sub _dashboard_export_add_columns {
+ my $self = shift;
+ my $c = $self->{c};
+
+ push @{$c->stash->{csv}->{headers}}, "Staff User";
+ push @{$c->stash->{csv}->{columns}}, "staff_user";
+
+ # All staff users, for contributed_by lookup
+ my @user_ids = $c->model('DB::User')->search(
+ { from_body => $self->body->id },
+ { columns => [ 'id', 'email', ] })->all;
+ my %user_lookup = map { $_->id => $_->email } @user_ids;
+
+ $c->stash->{csv}->{extra_data} = sub {
+ my $report = shift;
+ my $staff_user = '';
+ if (my $contributed_by = $report->get_extra_metadata('contributed_by')) {
+ $staff_user = $user_lookup{$contributed_by};
+ }
+ return {
+ staff_user => $staff_user,
+ };
+ };
+}
+
+sub dashboard_export_updates_add_columns {
+ shift->_dashboard_export_add_columns;
+}
+
+sub dashboard_export_problems_add_columns {
+ shift->_dashboard_export_add_columns;
+}
+
# Enable adding/editing of parish councils in the admin
sub add_extra_areas {
my ($self, $areas) = @_;
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index bb4a48d65..3ecb13b6a 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -716,4 +716,15 @@ sub encoded_content {
return encode_utf8($self->content);
}
+sub content_as_csv {
+ my $self = shift;
+ open my $data_handle, '<', \$self->content;
+ my $csv = Text::CSV->new({ binary => 1 });
+ my @rows;
+ while (my $row = $csv->getline($data_handle)) {
+ push @rows, $row;
+ }
+ return @rows;
+}
+
1;