Skip to content
Snippets Groups Projects
Commit 66621978 authored by Dan Braghis's avatar Dan Braghis
Browse files

DRY for staff check

parent c1b2adf8
No related branches found
No related tags found
No related merge requests found
...@@ -67,8 +67,7 @@ class Command(BaseCommand): ...@@ -67,8 +67,7 @@ class Command(BaseCommand):
'dev': 'Administrator', 'dev': 'Administrator',
} }
_, email_domain = user.get('mail').split('@') if self.is_staff(user['mail']):
if email_domain in settings.STAFF_EMAIL_DOMAINS:
groups.append(self.groups.filter(name=STAFF_GROUP_NAME).first()) groups.append(self.groups.filter(name=STAFF_GROUP_NAME).first())
roles = [role for role in user.get('roles').values() if role != "authenticated user"] roles = [role for role in user.get('roles').values() if role != "authenticated user"]
...@@ -81,11 +80,12 @@ class Command(BaseCommand): ...@@ -81,11 +80,12 @@ class Command(BaseCommand):
return groups return groups
def get_email(self, user, anonymize=False): def get_email(self, user, anonymize=False):
if not anonymize: email = user['mail']
return user['mail'] if not anonymize or self.is_staff(email):
return email
_, email_domain = user['mail'].split('@')
if email_domain in settings.STAFF_EMAIL_DOMAINS:
return user['mail']
return "aeon+%s@torchbox.com" % user['uid'] return "aeon+%s@torchbox.com" % user['uid']
def is_staff(self, email):
_, email_domain = email.split('@')
return email_domain in settings.STAFF_EMAIL_DOMAINS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment