From 43dd7d5e9026cd148bdfc36fac8f86f338f99440 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 29 Sep 2018 20:08:09 +0000 Subject: [PATCH] Tweaked the management command to send GDPR consent request emails to correctly perform exclusion based on the time of previous consent request emails. - Legacy-Id: 15504 --- ietf/utils/management/commands/send_gdpr_consent_request.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ietf/utils/management/commands/send_gdpr_consent_request.py b/ietf/utils/management/commands/send_gdpr_consent_request.py index a9c34a416..aa5676118 100644 --- a/ietf/utils/management/commands/send_gdpr_consent_request.py +++ b/ietf/utils/management/commands/send_gdpr_consent_request.py @@ -68,7 +68,8 @@ class Command(BaseCommand): if 'user' in options and options['user']: persons = Person.objects.filter(user__username__in=options['user']) else: - persons = Person.objects.exclude(consent=True).exclude(personevent__time__gt=latest_previous, personevent__type=event_type) + exclude = PersonEvent.objects.filter(time__gt=latest_previous, type=event_type) + persons = Person.objects.exclude(consent=True).exclude(personevent__in=exclude) # Report the size of the run runtime = persons.count() * delay self.stdout.write('Sending to %d users; estimated time a bit more than %d:%02d hours' % (persons.count(), runtime//3600, runtime%3600//60)) @@ -93,3 +94,4 @@ class Command(BaseCommand): e = PersonEvent.objects.create(person=person, type='gdpr_notice_email', desc="Sent GDPR notice email to %s with confirmation deadline %s" % (to, date)) time.sleep(delay) +