aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm59
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm178
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm6
-rw-r--r--t/app/controller/admin/users.t4
-rw-r--r--web/cobrands/sass/_layout.scss4
6 files changed, 138 insertions, 117 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ec954119..a9bc195ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
* Unreleased
- Bugfixes:
- - Don't remove automated fields when editing contacts #2163
+ - Don't remove automated fields when editing contacts #2163
+ - Remove small border to left of Fixed banner. #2156
+ - Fix issue displaying admin timeline. #2159
* v2.3.4 (7th June 2018)
- Bugfixes:
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 95969016f..9d6c7d922 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -13,6 +13,7 @@ use List::Util 'first';
use List::MoreUtils 'uniq';
use mySociety::ArrayUtils;
use Text::CSV;
+use Try::Tiny;
use FixMyStreet::SendReport;
use FixMyStreet::SMS;
@@ -142,43 +143,47 @@ sub timeline : Path( 'timeline' ) : Args(0) {
my %time;
- $c->model('DB')->schema->storage->sql_maker->quote_char( '"' );
- $c->model('DB')->schema->storage->sql_maker->name_sep( '.' );
+ try {
+ $c->model('DB')->schema->storage->sql_maker->quote_char( '"' );
+ $c->model('DB')->schema->storage->sql_maker->name_sep( '.' );
- my $probs = $c->cobrand->problems->timeline;
+ my $probs = $c->cobrand->problems->timeline;
- foreach ($probs->all) {
- push @{$time{$_->created->epoch}}, { type => 'problemCreated', date => $_->created, obj => $_ };
- push @{$time{$_->confirmed->epoch}}, { type => 'problemConfirmed', date => $_->confirmed, obj => $_ } if $_->confirmed;
- push @{$time{$_->whensent->epoch}}, { type => 'problemSent', date => $_->whensent, obj => $_ } if $_->whensent;
- }
-
- my $questionnaires = $c->model('DB::Questionnaire')->timeline( $c->cobrand->restriction );
+ foreach ($probs->all) {
+ push @{$time{$_->created->epoch}}, { type => 'problemCreated', date => $_->created, obj => $_ };
+ push @{$time{$_->confirmed->epoch}}, { type => 'problemConfirmed', date => $_->confirmed, obj => $_ } if $_->confirmed;
+ push @{$time{$_->whensent->epoch}}, { type => 'problemSent', date => $_->whensent, obj => $_ } if $_->whensent;
+ }
- foreach ($questionnaires->all) {
- push @{$time{$_->whensent->epoch}}, { type => 'quesSent', date => $_->whensent, obj => $_ };
- push @{$time{$_->whenanswered->epoch}}, { type => 'quesAnswered', date => $_->whenanswered, obj => $_ } if $_->whenanswered;
- }
+ my $questionnaires = $c->model('DB::Questionnaire')->timeline( $c->cobrand->restriction );
- my $updates = $c->cobrand->updates->timeline;
+ foreach ($questionnaires->all) {
+ push @{$time{$_->whensent->epoch}}, { type => 'quesSent', date => $_->whensent, obj => $_ };
+ push @{$time{$_->whenanswered->epoch}}, { type => 'quesAnswered', date => $_->whenanswered, obj => $_ } if $_->whenanswered;
+ }
- foreach ($updates->all) {
- push @{$time{$_->created->epoch}}, { type => 'update', date => $_->created, obj => $_} ;
- }
+ my $updates = $c->cobrand->updates->timeline;
- my $alerts = $c->model('DB::Alert')->timeline_created( $c->cobrand->restriction );
+ foreach ($updates->all) {
+ push @{$time{$_->created->epoch}}, { type => 'update', date => $_->created, obj => $_} ;
+ }
- foreach ($alerts->all) {
- push @{$time{$_->whensubscribed->epoch}}, { type => 'alertSub', date => $_->whensubscribed, obj => $_ };
- }
+ my $alerts = $c->model('DB::Alert')->timeline_created( $c->cobrand->restriction );
- $alerts = $c->model('DB::Alert')->timeline_disabled( $c->cobrand->restriction );
+ foreach ($alerts->all) {
+ push @{$time{$_->whensubscribed->epoch}}, { type => 'alertSub', date => $_->whensubscribed, obj => $_ };
+ }
- foreach ($alerts->all) {
- push @{$time{$_->whendisabled->epoch}}, { type => 'alertDel', date => $_->whendisabled, obj => $_ };
- }
+ $alerts = $c->model('DB::Alert')->timeline_disabled( $c->cobrand->restriction );
- $c->model('DB')->schema->storage->sql_maker->quote_char( '' );
+ foreach ($alerts->all) {
+ push @{$time{$_->whendisabled->epoch}}, { type => 'alertDel', date => $_->whendisabled, obj => $_ };
+ }
+ } catch {
+ die $_;
+ } finally {
+ $c->model('DB')->schema->storage->sql_maker->quote_char( '' );
+ };
$c->stash->{time} = \%time;
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index b2a0e331d..817fc48a1 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -7,6 +7,7 @@ use RABX;
use List::Util qw(min);
use Scalar::Util 'blessed';
use DateTime::Format::Pg;
+use Try::Tiny;
use strict;
use warnings;
@@ -1172,95 +1173,100 @@ sub admin_stats {
sub export_as_csv {
my ($self, $c, $params) = @_;
- $c->model('DB')->schema->storage->sql_maker->quote_char('"');
- my $csv = $c->stash->{csv} = {
- problems => $c->model('DB::Problem')->search_rs(
- $params,
- {
- join => ['admin_log_entries', 'user'],
- distinct => 1,
- columns => [
- 'id', 'created',
- 'latitude', 'longitude',
- 'cobrand', 'category',
- 'state', 'user_id',
- 'external_body',
- 'title', 'detail',
- 'photo',
- 'whensent', 'lastupdate',
- 'service',
- 'extra',
- { sum_time_spent => { sum => 'admin_log_entries.time_spent' } },
- 'name', 'user.id', 'user.email', 'user.phone', 'user.name',
- ]
- }
- ),
- headers => [
- 'Report ID', 'Created', 'Sent to Agency', 'Last Updated',
- 'E', 'N', 'Category', 'Status', 'Closure Status',
- 'UserID', 'User email', 'User phone', 'User name',
- 'External Body', 'Time Spent', 'Title', 'Detail',
- 'Media URL', 'Interface Used', 'Council Response',
- 'Strasse', 'Mast-Nr.', 'Haus-Nr.', 'Hydranten-Nr.',
- ],
- columns => [
- 'id', 'created', 'whensent',' lastupdate', 'local_coords_x',
- 'local_coords_y', 'category', 'state', 'closure_status',
- 'user_id', 'user_email', 'user_phone', 'user_name',
- 'body_name', 'sum_time_spent', 'title', 'detail',
- 'media_url', 'service', 'public_response',
- 'strasse', 'mast_nr',' haus_nr', 'hydranten_nr',
- ],
- extra_data => sub {
- my $report = shift;
-
- my $body_name = "";
- if ( my $external_body = $report->body($c) ) {
- $body_name = $external_body->name || '[Unknown body]';
- }
+ try {
+ $c->model('DB')->schema->storage->sql_maker->quote_char('"');
+ my $csv = $c->stash->{csv} = {
+ problems => $c->model('DB::Problem')->search_rs(
+ $params,
+ {
+ join => ['admin_log_entries', 'user'],
+ distinct => 1,
+ columns => [
+ 'id', 'created',
+ 'latitude', 'longitude',
+ 'cobrand', 'category',
+ 'state', 'user_id',
+ 'external_body',
+ 'title', 'detail',
+ 'photo',
+ 'whensent', 'lastupdate',
+ 'service',
+ 'extra',
+ { sum_time_spent => { sum => 'admin_log_entries.time_spent' } },
+ 'name', 'user.id', 'user.email', 'user.phone', 'user.name',
+ ]
+ }
+ ),
+ headers => [
+ 'Report ID', 'Created', 'Sent to Agency', 'Last Updated',
+ 'E', 'N', 'Category', 'Status', 'Closure Status',
+ 'UserID', 'User email', 'User phone', 'User name',
+ 'External Body', 'Time Spent', 'Title', 'Detail',
+ 'Media URL', 'Interface Used', 'Council Response',
+ 'Strasse', 'Mast-Nr.', 'Haus-Nr.', 'Hydranten-Nr.',
+ ],
+ columns => [
+ 'id', 'created', 'whensent',' lastupdate', 'local_coords_x',
+ 'local_coords_y', 'category', 'state', 'closure_status',
+ 'user_id', 'user_email', 'user_phone', 'user_name',
+ 'body_name', 'sum_time_spent', 'title', 'detail',
+ 'media_url', 'service', 'public_response',
+ 'strasse', 'mast_nr',' haus_nr', 'hydranten_nr',
+ ],
+ extra_data => sub {
+ my $report = shift;
+
+ my $body_name = "";
+ if ( my $external_body = $report->body($c) ) {
+ $body_name = $external_body->name || '[Unknown body]';
+ }
- my $detail = $report->detail;
- my $public_response = $report->get_extra_metadata('public_response') || '';
- my $metas = $report->get_extra_fields();
- my %extras;
- foreach my $field (@$metas) {
- $extras{$field->{name}} = $field->{value};
- }
+ my $detail = $report->detail;
+ my $public_response = $report->get_extra_metadata('public_response') || '';
+ my $metas = $report->get_extra_fields();
+ my %extras;
+ foreach my $field (@$metas) {
+ $extras{$field->{name}} = $field->{value};
+ }
- # replace newlines with HTML <br/> element
- $detail =~ s{\r?\n}{ <br/> }g;
- $public_response =~ s{\r?\n}{ <br/> }g if $public_response;
-
- # Assemble photo URL, if report has a photo
- my $photo_to_display = $c->cobrand->allow_photo_display($report);
- my $media_url = (@{$report->photos} && $photo_to_display)
- ? $c->cobrand->base_url . $report->photos->[$photo_to_display-1]->{url}
- : '';
-
- return {
- whensent => $report->whensent,
- lastupdate => $report->lastupdate,
- user_id => $report->user_id,
- user_email => $report->user->email || '',
- user_phone => $report->user->phone || '',
- user_name => $report->name,
- closure_status => $report->get_extra_metadata('closure_status') || '',
- body_name => $body_name,
- sum_time_spent => $report->get_column('sum_time_spent') || 0,
- detail => $detail,
- media_url => $media_url,
- service => $report->service || 'Web interface',
- public_response => $public_response,
- strasse => $extras{'strasse'} || '',
- mast_nr => $extras{'mast_nr'} || '',
- haus_nr => $extras{'haus_nr'} || '',
- hydranten_nr => $extras{'hydranten_nr'} || ''
- };
- },
- filename => 'stats',
+ # replace newlines with HTML <br/> element
+ $detail =~ s{\r?\n}{ <br/> }g;
+ $public_response =~ s{\r?\n}{ <br/> }g if $public_response;
+
+ # Assemble photo URL, if report has a photo
+ my $photo_to_display = $c->cobrand->allow_photo_display($report);
+ my $media_url = (@{$report->photos} && $photo_to_display)
+ ? $c->cobrand->base_url . $report->photos->[$photo_to_display-1]->{url}
+ : '';
+
+ return {
+ whensent => $report->whensent,
+ lastupdate => $report->lastupdate,
+ user_id => $report->user_id,
+ user_email => $report->user->email || '',
+ user_phone => $report->user->phone || '',
+ user_name => $report->name,
+ closure_status => $report->get_extra_metadata('closure_status') || '',
+ body_name => $body_name,
+ sum_time_spent => $report->get_column('sum_time_spent') || 0,
+ detail => $detail,
+ media_url => $media_url,
+ service => $report->service || 'Web interface',
+ public_response => $public_response,
+ strasse => $extras{'strasse'} || '',
+ mast_nr => $extras{'mast_nr'} || '',
+ haus_nr => $extras{'haus_nr'} || '',
+ hydranten_nr => $extras{'hydranten_nr'} || ''
+ };
+ },
+ filename => 'stats',
+ };
+ $c->forward('/dashboard/generate_csv');
+ } catch {
+ die $_;
+ } finally {
+ $c->model('DB')->schema->storage->sql_maker->quote_char('');
};
- $c->forward('/dashboard/generate_csv');
- $c->model('DB')->schema->storage->sql_maker->quote_char('');
}
sub problem_confirm_email_extras {
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index ef078ed08..967c90af5 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -198,9 +198,9 @@ sub timeline {
return $rs->search(
{
-or => {
- created => { '>=', \"current_timestamp-'7 days'::interval" },
- confirmed => { '>=', \"current_timestamp-'7 days'::interval" },
- whensent => { '>=', \"current_timestamp-'7 days'::interval" },
+ 'me.created' => { '>=', \"current_timestamp-'7 days'::interval" },
+ 'me.confirmed' => { '>=', \"current_timestamp-'7 days'::interval" },
+ 'me.whensent' => { '>=', \"current_timestamp-'7 days'::interval" },
}
},
{
diff --git a/t/app/controller/admin/users.t b/t/app/controller/admin/users.t
index 8759e260d..0d8290c37 100644
--- a/t/app/controller/admin/users.t
+++ b/t/app/controller/admin/users.t
@@ -450,4 +450,8 @@ subtest "Removing account from admin" => sub {
is $user->email, 'removed-' . $user->id . '@example.org', 'Email gone'
};
+subtest "View timeline" => sub {
+ $mech->get_ok('/admin/timeline');
+};
+
done_testing();
diff --git a/web/cobrands/sass/_layout.scss b/web/cobrands/sass/_layout.scss
index 8fbfb34ef..28a96c73d 100644
--- a/web/cobrands/sass/_layout.scss
+++ b/web/cobrands/sass/_layout.scss
@@ -761,6 +761,10 @@ body.authpage {
#{$left}: -0.75em;
border-#{$left}: 0.75em solid transparent;
border-bottom: 0.75em solid #888;
+ @media (min-width: 48em) {
+ border: 0;
+ #{$left}: 0;
+ }
}
}