aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Comment.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2017-09-18 16:46:47 +0100
committerStruan Donald <struan@exo.org.uk>2017-10-16 10:43:45 +0100
commit69cd91b70b488ebba89558cbc41d2472ecbbec5a (patch)
treec194ee28b98d79e250f0fe8adacf4f2e1eafb60e /perllib/FixMyStreet/DB/Result/Comment.pm
parent2404b1954614d9cd93c44e42a13449b7a7efaae1 (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/DB/Result/Comment.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm23
1 files changed, 17 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 409a6e1ab..60fd31510 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -229,13 +229,24 @@ sub meta_line {
if ($self->anonymous or !$self->name) {
$meta = sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) )
- } elsif ($self->user->from_body) {
+ } elsif ($self->user->from_body || $self->get_extra_metadata('is_body_user') || $self->get_extra_metadata('is_superuser') ) {
my $user_name = FixMyStreet::Template::html_filter($self->user->name);
- my $body = $self->user->body;
- if ($body eq 'Bromley Council') {
- $body = "$body <img src='/cobrands/bromley/favicon.png' alt=''>";
- } elsif ($body eq 'Royal Borough of Greenwich') {
- $body = "$body <img src='/cobrands/greenwich/favicon.png' alt=''>";
+ my $body;
+ if ($self->get_extra_metadata('is_superuser')) {
+ $body = _('an administrator');
+ } else {
+ # use this meta data in preference to the user's from_body setting
+ # in case they are no longer with the body, or have changed body.
+ if (my $body_id = $self->get_extra_metadata('is_body_user')) {
+ $body = FixMyStreet::App->model('DB::Body')->find({id => $body_id})->name;
+ } else {
+ $body = $self->user->body;
+ }
+ if ($body eq 'Bromley Council') {
+ $body = "$body <img src='/cobrands/bromley/favicon.png' alt=''>";
+ } elsif ($body eq 'Royal Borough of Greenwich') {
+ $body = "$body <img src='/cobrands/greenwich/favicon.png' alt=''>";
+ }
}
my $can_view_contribute = $c->user_exists && $c->user->has_permission_to('view_body_contribute_details', $self->problem->bodies_str_ids);
if ($self->text) {