From: Daniel Axtens Date: Tue, 11 Jul 2017 06:30:48 +0000 (+1000) Subject: cron: fix deletion of unactivated accounts X-Git-Tag: v2.0.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ada8ccd1a89c274a6db68104f78f5d4aff4e943;p=thirdparty%2Fpatchwork.git cron: fix deletion of unactivated accounts There is a test in expire_notifications() that tries to check if the user's last login matches the date joined. (I think the login date is not set until a post-activation login.) This does not work: on patchwork.ozlabs.org there are 10k users that have never been deleted. Drop the date test: it should be sufficient that a user is not active and their confirmation is not pending. Reported-by: Stephen Rothwell Signed-off-by: Daniel Axtens Reviewed-by: Stephen Finucane --- diff --git a/patchwork/notifications.py b/patchwork/notifications.py index 16152ef9..840d2cf9 100644 --- a/patchwork/notifications.py +++ b/patchwork/notifications.py @@ -25,7 +25,8 @@ from django.conf import settings from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.core.mail import EmailMessage -from django.db.models import Count, Q, F +from django.db.models import Count +from django.db.models import Q from patchwork.compat import render_to_string from patchwork.models import EmailConfirmation @@ -109,9 +110,7 @@ def expire_notifications(): # remove inactive users with no pending confirmation pending_confs = EmailConfirmation.objects.values('user') - users = User.objects.filter(is_active=False, - last_login=F('date_joined')).exclude( - id__in=pending_confs) + users = User.objects.filter(is_active=False).exclude(id__in=pending_confs) # delete users users.delete()