From 7ada8ccd1a89c274a6db68104f78f5d4aff4e943 Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Tue, 11 Jul 2017 16:30:48 +1000 Subject: [PATCH] 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 --- patchwork/notifications.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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() -- 2.47.3