aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-10-08 12:00:17 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-10-11 22:31:15 +0100
commita91ee9b19d21754f91bed26118b7cd9a2b2cc6d4 (patch)
treed8a4a5151c7d64029ae849467b0d157d3762e973
parent3909c8655d118402c798653d188515d7dc406b03 (diff)
[Bexley] Different message for anonymous updates.
-rw-r--r--perllib/FixMyStreet/Cobrand/Bexley.pm8
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm3
-rw-r--r--t/cobrand/bexley.t12
3 files changed, 21 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm
index 215b9d2cb..2c05439be 100644
--- a/perllib/FixMyStreet/Cobrand/Bexley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bexley.pm
@@ -221,4 +221,12 @@ sub _is_out_of_hours {
return 0;
}
+sub update_anonymous_message {
+ my ($self, $update) = @_;
+ my $t = Utils::prettify_dt( $update->confirmed );
+
+ my $staff = $update->user->from_body || $update->get_extra_metadata('is_body_user') || $update->get_extra_metadata('is_superuser');
+ return sprintf('Posted anonymously by a non-staff user at %s', $t) if !$staff;
+}
+
1;
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 76e8d3185..82476ba10 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -272,7 +272,8 @@ sub meta_line {
my $anon = $self->anonymous || !$self->name;
if ($anon && (!$staff || $contributed_as eq 'anonymous_user' || $contributed_as eq 'another_user')) {
- $meta = sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) )
+ $meta = $cobrand->call_hook(update_anonymous_message => $self);
+ $meta ||= sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) )
} elsif ($staff) {
my $user_name = FixMyStreet::Template::html_filter($self->user->name);
my $body;
diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t
index 8ce6c45f2..46a25d923 100644
--- a/t/cobrand/bexley.t
+++ b/t/cobrand/bexley.t
@@ -147,7 +147,7 @@ FixMyStreet::override_config {
subtest 'resend is disabled in admin' => sub {
my $user = $mech->log_in_ok('super@example.org');
- $user->update({ from_body => $body, is_superuser => 1 });
+ $user->update({ from_body => $body, is_superuser => 1, name => 'Staff User' });
$mech->get_ok('/admin/report_edit/' . $report->id);
$mech->content_contains('View report on site');
$mech->content_lacks('Resend report');
@@ -202,6 +202,16 @@ FixMyStreet::override_config {
], 'Request had multiple photos';
};
+ subtest 'anonymous update message' => sub {
+ my $report = FixMyStreet::DB->resultset("Problem")->first;
+ my $staffuser = $mech->create_user_ok('super@example.org');
+ $mech->create_comment_for_problem($report, $report->user, 'Commenter', 'Normal update', 't', 'confirmed', 'confirmed');
+ $mech->create_comment_for_problem($report, $staffuser, 'Staff user', 'Staff update', 'f', 'confirmed', 'confirmed');
+ $mech->get_ok('/report/' . $report->id);
+ $mech->content_contains('Posted by <strong>London Borough of Bexley</strong>');
+ $mech->content_contains('Posted anonymously by a non-staff user');
+ };
+
};
subtest 'nearest road returns correct road' => sub {