aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-06-09 15:18:16 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-06-09 17:00:42 +0100
commit6088d10642da56cbea96446da9d9cd87c922ede5 (patch)
tree448e2aed96b2cc66ac22bb428fee218b6f188590
parente1c8f0dadbcdf1f8511ec673c2e6892207fca328 (diff)
[Highways England] Anonymize all names on cobrand.
-rw-r--r--perllib/FixMyStreet/App/Controller/JSON.pm1
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/HighwaysEngland.pm9
-rw-r--r--t/cobrand/highwaysengland.t18
5 files changed, 25 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm
index a7913bb4b..4657fcf2c 100644
--- a/perllib/FixMyStreet/App/Controller/JSON.pm
+++ b/perllib/FixMyStreet/App/Controller/JSON.pm
@@ -101,6 +101,7 @@ sub problems : Local {
} );
foreach my $problem (@problems) {
+ $c->cobrand->call_hook(munge_problem_list => $problem);
$problem->name( '' ) if $problem->anonymous == 1;
$problem->service( 'Web interface' ) if $problem->service eq '';
my $body_names = $problem->body_names;
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 31cf84874..73a91a62a 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -220,6 +220,8 @@ sub output_requests : Private {
my @problemlist;
while ( my $problem = $problems->next ) {
+ $c->cobrand->call_hook(munge_problem_list => $problem);
+
my $id = $problem->id;
$problem->service( 'Web interface' ) unless $problem->service;
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 4d8794c59..4f9825cae 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -197,6 +197,7 @@ sub load_problem_or_display_error : Private {
}
}
+ $c->cobrand->call_hook(munge_problem_list => $problem);
$c->stash->{problem} = $problem;
if ( $c->user_exists && $c->user->can_moderate($problem) ) {
$c->stash->{problem_original} = $problem->find_or_new_related(
@@ -251,6 +252,7 @@ sub load_updates : Private {
my @combined;
my %questionnaires_with_updates;
while (my $update = $updates->next) {
+ $c->cobrand->call_hook(munge_update_list => $update);
push @combined, [ $update->confirmed, $update ];
if (my $qid = $update->get_extra_metadata('questionnaire_id')) {
$questionnaires_with_updates{$qid} = $update;
diff --git a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
index ed58eb4f7..c282ac5ea 100644
--- a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
+++ b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
@@ -29,6 +29,15 @@ sub users_restriction { FixMyStreet::Cobrand::UKCouncils::users_restriction($_[0
sub updates_restriction { FixMyStreet::Cobrand::UKCouncils::updates_restriction($_[0], $_[1]) }
sub base_url { FixMyStreet::Cobrand::UKCouncils::base_url($_[0]) }
+sub munge_problem_list {
+ my ($self, $problem) = @_;
+ $problem->anonymous(1);
+}
+sub munge_update_list {
+ my ($self, $update) = @_;
+ $update->anonymous(1);
+}
+
sub admin_allow_user {
my ( $self, $user ) = @_;
return 1 if $user->is_superuser;
diff --git a/t/cobrand/highwaysengland.t b/t/cobrand/highwaysengland.t
index f6400ea7c..0b71c613f 100644
--- a/t/cobrand/highwaysengland.t
+++ b/t/cobrand/highwaysengland.t
@@ -29,12 +29,11 @@ my $highways = $mech->create_body_ok(2234, 'Highways England');
$mech->create_contact_ok(email => 'highways@example.com', body_id => $highways->id, category => 'Pothole');
-# Br1 3UH
-subtest "check where heard from saved" => sub {
- FixMyStreet::override_config {
- ALLOWED_COBRANDS => 'highwaysengland',
- MAPIT_URL => 'http://mapit.uk/',
- }, sub {
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'highwaysengland',
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+ subtest "check where heard from saved" => sub {
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'M1, J16', } }, "submit location" );
$mech->follow_link_ok( { text_regex => qr/skip this step/i, },
@@ -64,7 +63,12 @@ subtest "check where heard from saved" => sub {
like $mech->get_text_body_from_email($email), qr/Heard from: Facebook/, 'where hear included in email'
};
-};
+ subtest "check anonymous display" => sub {
+ my ($problem) = $mech->create_problems_for_body(1, $highways->id, 'Title');
+ $mech->get_ok('/report/' . $problem->id);
+ $mech->content_lacks('Reported by Test User at');
+ };
+};
done_testing();