aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-11-25 18:09:26 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-11-25 18:09:26 +0000
commit8531ba29675c046d71f6e99e3ad2f6cd72a3c584 (patch)
treee5828d7cbde500f2e2498619d5f4b8701d3aff68
parent857c9f918a9c572e9e255073a2984c526ea2a075 (diff)
[UK] Include specific domain in user search.
This deals with a bootstrapping issue of adding new admin users that haven't yet interacted with the system.
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm15
2 files changed, 13 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index a476b5e9b..dca208e98 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -119,4 +119,6 @@ sub contact_email {
return join( '@', 'highway.enquiries', 'oxfordshire.gov.uk' );
}
+sub admin_user_domain { 'oxfordshire.gov.uk' }
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 42c9c5cbc..c22224307 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -55,8 +55,9 @@ sub updates_restriction {
sub users_restriction {
my ($self, $rs) = @_;
- # Council admins can only see users who are members of the same council or
- # users who have sent a report or update to that council.
+ # Council admins can only see users who are members of the same council,
+ # have an email address in a specified domain, or users who have sent a
+ # report or update to that council.
my $problem_user_ids = $self->problems->search(
undef,
@@ -73,10 +74,16 @@ sub users_restriction {
}
)->as_query;
- return $rs->search([
+ my $or_query = [
from_body => $self->council_id,
id => [ { -in => $problem_user_ids }, { -in => $update_user_ids } ],
- ]);
+ ];
+ if ($self->can('admin_user_domain')) {
+ my $domain = $self->admin_user_domain;
+ push @$or_query, email => { ilike => "%\@$domain" };
+ }
+
+ return $rs->search($or_query);
}
sub base_url {