diff options
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 17 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 2 | ||||
-rw-r--r-- | templates/web/default/report/updates.html | 3 |
3 files changed, 22 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index ade8ca934..577d91c31 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -142,4 +142,21 @@ sub alert_for_problem { } ); } +sub council { + my $self = shift; + + return '' unless $self->from_council; + + my $key = 'council_name:' . $self->from_council; + my $result = Memcached::get($key); + + unless ($result) { + my $area_info = mySociety::MaPit::call('area', $self->from_council); + $result = $area_info->{name}; + Memcached::set($key, $result, 86400); + } + + return $result; +} + 1; diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 35e8b9e5f..16165e8ae 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -534,6 +534,8 @@ for my $test ( my $update_meta = $mech->extract_update_metas; like $update_meta->[0], qr/marked as $test->{fields}->{state}$/, 'update meta includes state change'; + like $update_meta->[0], qr{Test User \(Westminster City Council\)}, 'update meta includes council name'; + $mech->content_contains( 'Test User (<strong>Westminster City Council</strong>)', 'council name in bold'); $report->discard_changes; is $report->state, $test->{state}, 'state set'; diff --git a/templates/web/default/report/updates.html b/templates/web/default/report/updates.html index 95a2c7b38..803ed197e 100644 --- a/templates/web/default/report/updates.html +++ b/templates/web/default/report/updates.html @@ -6,6 +6,9 @@ <div><div class="problem-update"><p><a name="update_[% update.id %]"></a><em> [% IF update.anonymous || update.name == '' %] [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed_local.epoch ) ) -%] + [%- ELSIF update.user.from_council %] + [% user_name = update.user.name | html %] + [% tprintf( loc( 'Posted by %s (<strong>%s</strong>) at %s' ), user_name, update.user.council, prettify_epoch( update.confirmed_local.epoch ) ) -%] [%- ELSE %] [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html -%] [%- END -%] |