-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete accounts that are not staff #1615
Conversation
- Add scheduler
As long as people who can log in and edit continue to be able to, even if they're not |
…ask is running for 10s every sunday
I decided to remove apscheduler: I realized that the @alanmoo the current setup would kick Luca's account. I'll check if people are part of a group or not too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one minor thing to update in the non-staff query.
I also think we should write and execute these kind of tasks as Django management commands - can you move it to the network-api/networkapi/management/commands
folder and wrap it in the required classes for it to be callable by manage.py?
network-api/delete_non_staff.py
Outdated
print("Deleting non staff users") | ||
group_q = Group.objects.all() | ||
non_staff = User.objects.exclude( | ||
Q(email__contains='mozillafoundation.org') | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be Q(email__endswith='@mozillafoundation.org') |
, which will ensure sneaky people don't get by with something like "trollolol+mozillafoundation.org@example.com" - which seems unlikely, but lets just protect against it anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am totally going to start using that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're totally right, let's fix that XD
network-api/networkapi/tests.py
Outdated
def setUp(self): | ||
User.objects.create(username='Alex', email='alex@mozillafoundation.org') | ||
|
||
def test_mozilla_Foundation_users_not_deleted(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix the capitalization of this test name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
close MozillaFoundation/mofo-devops-private#140
Add a scheduled task that will run every week to remove any accounts that are not staff or with a '@mozillafoundation.org' email address.
@alanmoo I am kicking people out that I shouldn't with this rule?
Post-merge todo:
python network-api/manage.py delete_non_staff
to prod