diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-11-07 09:33:52 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-11-08 15:32:09 +0000 |
commit | 8fb05a1e55bd2534ebd6cbba0b95f750b41ab6bd (patch) | |
tree | 8a85e0db405860fff43be62d65bade1b10beb62c | |
parent | 7a39608ab48c8fd3fa2c5a8061b42ee8f9869973 (diff) |
Store a moderation history on admin report edit.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Reports.pm | 17 | ||||
-rw-r--r-- | t/app/controller/admin/report_edit.t | 7 |
2 files changed, 23 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm index 895bc17a8..bee2ed498 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm @@ -293,6 +293,22 @@ sub edit : Path('/admin/report_edit') : Args(1) { foreach (qw/state anonymous title detail name external_id external_body external_team/) { $columns{$_} = $c->get_param($_); } + + # Look this up here for moderation line to use + my $remove_photo_param = $c->forward('/admin/_get_remove_photo_param'); + + if ($columns{title} ne $problem->title || $columns{detail} ne $problem->detail || + $columns{anonymous} ne $problem->anonymous || $remove_photo_param) { + $problem->create_related( moderation_original_data => { + title => $problem->title, + detail => $problem->detail, + photo => $problem->photo, + anonymous => $problem->anonymous, + category => $problem->category, + $problem->extra ? (extra => $problem->extra) : (), + }); + } + $problem->set_inflated_columns(\%columns); if ($c->get_param('closed_updates')) { @@ -305,7 +321,6 @@ sub edit : Path('/admin/report_edit') : Args(1) { $c->forward('/admin/update_user', [ $problem ]); # Deal with photos - my $remove_photo_param = $c->forward('/admin/_get_remove_photo_param'); if ($remove_photo_param) { $c->forward('/admin/remove_photo', [ $problem, $remove_photo_param ]); } diff --git a/t/app/controller/admin/report_edit.t b/t/app/controller/admin/report_edit.t index 1a2e8f1bf..85f83781c 100644 --- a/t/app/controller/admin/report_edit.t +++ b/t/app/controller/admin/report_edit.t @@ -412,6 +412,13 @@ foreach my $test ( delete $test->{changes}->{closed_updates}; } + if ($test->{changes}{title} || $test->{changes}{detail} || $test->{changes}{anonymous}) { + $mech->get_ok("/report/$report_id"); + $mech->content_contains("Anonymous: <del style='background-color:#fcc'>No</del><ins style='background-color:#cfc'>Yes</ins>") if $test->{changes}{anonymous}; + $mech->content_contains("Details: <ins style='background-color:#cfc'>Edited </ins>Detail<del style='background-color:#fcc'> for Report to Edit</del>") if $test->{changes}{detail}; + $mech->content_contains("Subject: <ins style='background-color:#cfc'>Edited </ins>Repor<del style='background-color:#fcc'>t to Edi</del>") if $test->{changes}{title}; + } + is $report->$_, $test->{changes}->{$_}, "$_ updated" for grep { $_ ne 'username' } keys %{ $test->{changes} }; if ( $test->{user} ) { |