Compare commits
No commits in common. "73cf94515d3446659c8db84441a2fec4a79e943c" and "a983aafba271cf5dd47c88b07530f886a54b3536" have entirely different histories.
73cf94515d
...
a983aafba2
|
@ -1,24 +0,0 @@
|
|||
from collections import defaultdict
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from accounts import models as acc_models
|
||||
from django.contrib.auth import models as auth_models
|
||||
from django.contrib.auth.models import timezone
|
||||
from datetime import timedelta
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Remove all users who never logged in'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
all_users = acc_models.UserProfileInfo.objects.filter(score=0).select_related()
|
||||
to_remove = []
|
||||
for elem in all_users:
|
||||
user = elem.user
|
||||
if user.last_login is None and user.date_joined < timezone.now() - timedelta(hours=72):
|
||||
to_remove.append(user)
|
||||
print("You are going to remove {} users.".format(len(to_remove)))
|
||||
answer = input("Continue ? [y/N] ")
|
||||
|
||||
if answer.lower() in ["y","yes"]:
|
||||
for elem in to_remove:
|
||||
elem.delete()
|
||||
print("Users have been successfully pruned.")
|
Loading…
Reference in New Issue