aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--docs/_includes/admin-tasks-content.md3
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm18
-rw-r--r--perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm9
-rw-r--r--t/app/controller/moderate.t9
-rw-r--r--templates/web/base/admin/report_edit.html13
-rw-r--r--templates/web/base/report/update.html6
-rw-r--r--templates/web/base/report/update/moderation.html6
-rw-r--r--templates/web/base/report/update/moderation_diff.html9
-rw-r--r--templates/web/base/report/update/moderation_meta.html3
10 files changed, 62 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8bf5b21ea..ee49e4ced 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
## Releases
* Unreleased
+ - Admin improvements:
+ - Include moderation history in report updates. #2379
- Bugfixes
- Check cached reports do still have photos before being shown.
- Delete cache photos upon photo moderation.
diff --git a/docs/_includes/admin-tasks-content.md b/docs/_includes/admin-tasks-content.md
index 3a6b60ab9..3a93b284f 100644
--- a/docs/_includes/admin-tasks-content.md
+++ b/docs/_includes/admin-tasks-content.md
@@ -215,6 +215,9 @@ update. Clicking this button gives you the ability to:
You can also add a note to indicate the reason for the change to the report.
+Moderation history will be shown within the report updates, and is only visible to people with
+the moderate permission.
+
#### Hiding reports
Clicking the moderation button also gives you the option to hide an entire report or its updates.
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 58ce64af6..3078a4a2e 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -233,6 +233,24 @@ sub load_updates : Private {
next if $questionnaires_with_updates{$q->id};
push @combined, [ $q->whenanswered, $q ];
}
+
+ # And include moderation changes...
+ my $problem = $c->stash->{problem};
+ my $public_history = $c->cobrand->call_hook(public_moderation_history => $problem);
+ my $user_can_moderate = $c->user_exists && $c->user->can_moderate($problem);
+ if ($public_history || $user_can_moderate) {
+ my @history = $problem->moderation_history;
+ my $last_history = $problem;
+ foreach my $history (@history) {
+ push @combined, [ $history->created, {
+ type => 'moderation',
+ last => $last_history,
+ entry => $history,
+ } ];
+ $last_history = $history;
+ }
+ }
+
@combined = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @combined;
$c->stash->{updates} = \@combined;
diff --git a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm
index 01ae1d6e1..1e61b946a 100644
--- a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm
+++ b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm
@@ -167,7 +167,14 @@ sub compare_extra {
push @s, string_diff("$_ = $old->{$_}", "");
}
}
- return join ', ', @s;
+ return join ', ', grep { $_ } @s;
+}
+
+sub extra_diff {
+ my ($self, $other, $key) = @_;
+ my $o = $self->get_extra_metadata($key);
+ my $n = $other->get_extra_metadata($key);
+ return string_diff($o, $n);
}
sub string_diff {
diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t
index 4eb72ed56..36a4bfbbd 100644
--- a/t/app/controller/moderate.t
+++ b/t/app/controller/moderate.t
@@ -257,8 +257,12 @@ subtest 'Problem moderation' => sub {
$report->discard_changes;
is $report->get_extra_metadata('weather'), 'snow';
is $report->get_extra_metadata('moon'), 'waning full';
- is $report->moderation_original_data->get_extra_metadata('moon'), 'waxing full';
- is $report->moderation_original_data->get_extra_metadata('weather'), undef;
+ my $mod = $report->moderation_original_data;
+ is $mod->get_extra_metadata('moon'), 'waxing full';
+ is $mod->get_extra_metadata('weather'), undef;
+
+ my $diff = $mod->extra_diff($report, 'moon');
+ is $diff, "wa<del style='background-color:#fcc'>x</del><ins style='background-color:#cfc'>n</ins>ing full", 'Correct diff';
};
subtest 'Moderate category' => sub {
@@ -327,6 +331,7 @@ sub create_update {
text => 'update good good bad good',
state => 'confirmed',
mark_fixed => 0,
+ confirmed => $dt,
});
}
my %update_prepopulated = (
diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html
index 175863549..a28950e27 100644
--- a/templates/web/base/admin/report_edit.html
+++ b/templates/web/base/admin/report_edit.html
@@ -189,17 +189,8 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a>
[% last_history = problem %]
<ul>
[% FOR history IN moderation_history %]
- [% SET diff = history.compare_with(last_history) %]
- [% SET log = history.admin_log %]
- <li><i>[% tprintf(loc('Moderated by %s at %s'), log.user.name OR loc('an administrator'), prettify_dt(history.created)) %]
- [%~ IF log.reason %]<br>“[% log.reason %]”[% END %]</i>
- [% IF diff.title %]<br>[% loc('Subject:') %] [% diff.title %][% END %]
- [% IF diff.detail %]<br>[% loc('Details:') %] [% diff.detail %][% END %]
- [% IF diff.photo %]<br>[% loc('Photo') %]: [% diff.photo %][% END %]
- [% IF diff.anonymous %]<br>[% loc('Anonymous:') %] [% diff.anonymous %][% END %]
- [% IF diff.coords %]<br>[% loc('Latitude/Longitude:') %] [% diff.coords %][% END %]
- [% IF diff.category %]<br>[% loc('Category:') %] [% diff.category %][% END %]
- [% IF diff.extra %]<br>[% loc('Extra data:') %] [% diff.extra %][% END %]
+ <li><i>[% INCLUDE 'report/update/moderation_meta.html' %]</i>
+ [% INCLUDE 'report/update/moderation_diff.html' diff=history.compare_with(last_history) %]
</li>
[% last_history = history %]
[% END %]
diff --git a/templates/web/base/report/update.html b/templates/web/base/report/update.html
index bac28dd11..6c837b07c 100644
--- a/templates/web/base/report/update.html
+++ b/templates/web/base/report/update.html
@@ -1,11 +1,11 @@
-[% can_moderate = NOT update.whenanswered AND (permissions.moderate OR c.user.can_moderate(update, staff = permissions.moderate)) %]
+[% can_moderate = NOT update.whenanswered AND update.type != 'moderation' AND (permissions.moderate OR c.user.can_moderate(update, staff = permissions.moderate)) %]
[% IF loop.first %]
<section class="full-width">
<h4 class="static-with-rule">[% loc('Updates') %]</h4>
<ul class="item-list item-list--updates">
[% END %]
<li class="item-list__item item-list__item--updates
- [%~ ' show-moderation' IF show_moderation == update.id ~%]
+ [%~ ' show-moderation' IF update.id AND show_moderation == update.id ~%]
">
<a name="update_[% update.id %]" class="internal-link-fixed-header"></a>
[% IF can_moderate; original_update = update.moderation_original_data %]
@@ -29,6 +29,8 @@
<div class="item-list__update-text">
<p class="meta-2">[% INCLUDE meta_line %]</p>
</div>
+ [% ELSIF update.type == 'moderation' %]
+ [% PROCESS 'report/update/moderation.html' %]
[% ELSE %]
[% INCLUDE 'report/photo.html' object=update %]
<div class="item-list__update-text">
diff --git a/templates/web/base/report/update/moderation.html b/templates/web/base/report/update/moderation.html
new file mode 100644
index 000000000..3ec9572ef
--- /dev/null
+++ b/templates/web/base/report/update/moderation.html
@@ -0,0 +1,6 @@
+<div class="item-list__update-text">
+ [% INCLUDE 'report/update/moderation_diff.html' diff=update.entry.compare_with(update.last) %]
+ <p class="meta-2">
+ [% INCLUDE 'report/update/moderation_meta.html' history=update.entry %]
+ </p>
+</div>
diff --git a/templates/web/base/report/update/moderation_diff.html b/templates/web/base/report/update/moderation_diff.html
new file mode 100644
index 000000000..1d53736f0
--- /dev/null
+++ b/templates/web/base/report/update/moderation_diff.html
@@ -0,0 +1,9 @@
+<ul>
+ [% IF diff.title %]<li>[% loc('Subject:') %] [% diff.title %][% END %]
+ [% IF diff.detail %]<li>[% loc('Details:') %] [% diff.detail %][% END %]
+ [% IF diff.photo %]<li>[% loc('Photo') %]: [% diff.photo %][% END %]
+ [% IF diff.anonymous %]<li>[% loc('Anonymous:') %] [% diff.anonymous %][% END %]
+ [% IF diff.coords %]<li>[% loc('Latitude/Longitude:') %] [% diff.coords %][% END %]
+ [% IF diff.category %]<li>[% loc('Category:') %] [% diff.category %][% END %]
+ [% IF diff.extra %]<li>[% loc('Extra data:') %] [% diff.extra %][% END %]
+</ul>
diff --git a/templates/web/base/report/update/moderation_meta.html b/templates/web/base/report/update/moderation_meta.html
new file mode 100644
index 000000000..571b04850
--- /dev/null
+++ b/templates/web/base/report/update/moderation_meta.html
@@ -0,0 +1,3 @@
+[% SET log = history.admin_log %]
+[%~ tprintf(loc('Moderated by %s at %s'), log.user.name OR loc('an administrator'), prettify_dt(history.created)) %]
+[%~ IF log.reason %], “[% log.reason %]”[% END %]