diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Moderate.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 23 |
3 files changed, 40 insertions, 8 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' ] ); diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm index 1313b5071..42dc759e5 100644 --- a/perllib/FixMyStreet/App/Controller/Moderate.pm +++ b/perllib/FixMyStreet/App/Controller/Moderate.pm @@ -85,7 +85,7 @@ sub moderate_report : Chained('report') : PathPart('') : Args(0) { sub moderating_user_name { my $user = shift; - return $user->from_body ? $user->from_body->name : 'a FixMyStreet administrator'; + return $user->from_body ? $user->from_body->name : _('an administrator'); } sub report_moderate_audit : Private { 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) { |