diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 13 | ||||
-rw-r--r-- | t/app/controller/admin/report_edit.t | 26 | ||||
-rw-r--r-- | templates/web/base/admin/report_edit.html | 1 |
4 files changed, 42 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d58c6e30d..cd474a6cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Allow cobrands to override searching by reference #2271 - Front end improvements: - Clearer relocation options while you’re reporting a problem #2238 + - Admin improvements + - List number of alerts on report page #669 - Bugfixes: - Add perl 5.26/5.28 support. - Fix subcategory issues when visiting /report/new directly #2276 diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 1158b688a..504de19ca 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -883,6 +883,8 @@ sub report_edit : Path('report_edit') : Args(1) { $c->forward('categories_for_point'); + $c->forward('alerts_for_report'); + $c->forward('check_username_for_abuse', [ $problem->user ] ); $c->stash->{updates} = @@ -1111,6 +1113,17 @@ sub categories_for_point : Private { $c->stash->{categories_hash} = { map { $_->category => 1 } @{$c->stash->{category_options}} }; } +sub alerts_for_report : Private { + my ($self, $c) = @_; + + $c->stash->{alert_count} = $c->model('DB::Alert')->search({ + alert_type => 'new_updates', + parameter => $c->stash->{report}->id, + confirmed => 1, + whendisabled => undef, + })->count(); +} + sub templates : Path('templates') : Args(0) { my ( $self, $c ) = @_; diff --git a/t/app/controller/admin/report_edit.t b/t/app/controller/admin/report_edit.t index 5e3e6c315..c6e03ff7e 100644 --- a/t/app/controller/admin/report_edit.t +++ b/t/app/controller/admin/report_edit.t @@ -608,6 +608,32 @@ subtest "Test display of report extra data" => sub { $mech->content_contains('extra_field</strong>: this is extra data'); }; +subtest "Test alert count display" => sub { + $mech->get_ok("/admin/report_edit/$report_id"); + $mech->content_contains('Alerts: 0'); + + my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create( + { + alert_type => 'new_updates', + parameter => $report_id, + user => $user, + } + ); + + $mech->get_ok("/admin/report_edit/$report_id"); + $mech->content_contains('Alerts: 0', 'does not include unconfirmed reports'); + + $alert->update( { confirmed => 1 } ); + $mech->get_ok("/admin/report_edit/$report_id"); + $mech->content_contains('Alerts: 1'); + + $alert->update( { whendisabled => \"now()" } ); + $mech->get_ok("/admin/report_edit/$report_id"); + $mech->content_contains('Alerts: 0'); + + $alert->delete; +}; + my $report2 = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index 10eb0eea1..794e19e4c 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -88,6 +88,7 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a> [% END %] </li> <li class="sm">[% loc('Last update:') %] [% PROCESS format_time time=problem.lastupdate %]</li> +<li>[% loc('Alerts:') %] [% alert_count %]</li> <li>[% loc('Service:') %] [% problem.service OR '<em>' _ loc('None') _ '</em>' %]</li> <li>[% loc('Cobrand:') %] [% problem.cobrand %] <br><small>[% loc('Cobrand data:') %] [% cobrand_data OR '<em>' _ loc('None') _ '</em>' %]</small> |