diff options
author | Struan Donald <struan@exo.org.uk> | 2017-09-18 16:46:47 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2017-10-16 10:43:45 +0100 |
commit | 69cd91b70b488ebba89558cbc41d2472ecbbec5a (patch) | |
tree | c194ee28b98d79e250f0fe8adacf4f2e1eafb60e /perllib/FixMyStreet/App/Controller/Admin.pm | |
parent | 2404b1954614d9cd93c44e42a13449b7a7efaae1 (diff) |
log all state changes in admin as comments
Create a comment on a problem when the admin is used to change the state
of the problem. If only the state is changed then create a comment with
blank text. If the category and state are changing then include details
of the category change in the comment.
Not all the state changes are displayed at the template level by
default.
Fixes #1846
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 719b04cf6..82041a6b1 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -913,7 +913,7 @@ sub report_edit : Path('report_edit') : Args(1) { } $problem->set_inflated_columns(\%columns); - $c->forward( '/admin/report_edit_category', [ $problem ] ); + $c->forward( '/admin/report_edit_category', [ $problem, $problem->state ne $old_state ] ); $c->forward('update_user', [ $problem ]); # Deal with photos @@ -935,6 +935,27 @@ sub report_edit : Path('report_edit') : Args(1) { if ( $problem->state ne $old_state ) { $c->forward( 'log_edit', [ $id, 'problem', 'state_change' ] ); + + my $name = _('an adminstrator'); + my $extra = { is_superuser => 1 }; + if ($c->user->from_body) { + $name = $c->user->from_body->name; + delete $extra->{is_superuser}; + $extra->{is_body_user} = $c->user->from_body->id; + } + my $timestamp = \'current_timestamp'; + $problem->add_to_comments( { + text => $c->stash->{update_text} || '', + created => $timestamp, + confirmed => $timestamp, + user_id => $c->user->id, + name => $name, + mark_fixed => 0, + anonymous => 0, + state => 'confirmed', + problem_state => $problem->state, + extra => $extra + } ); } $c->forward( 'log_edit', [ $id, 'problem', 'edit' ] ); |