Skip to content

Commit

Permalink
Fix potentially incorrectly deleting old paid registrations/renewals (#…
Browse files Browse the repository at this point in the history
…3736)

While this should be impossible in practice already, this ensures that
no registations/renewals are deleted *outside of dataminimisation* that
were actually paid/completed.

This makes it more certain that invoices for paid registrations are not
accidentally getting deleted.
  • Loading branch information
DeD1rk authored Jul 10, 2024
1 parent d9b6f55 commit 95d00e7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions website/registrations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ def minimise_registrations():

@shared_task
def notify_old_entries():
# delete entries w updated_at 1 month ago and created_at 3m ago
# notify (and update updated_at) entries w updated_at 1 month ago

Registration.objects.filter(
"""Delete very old entries and send a reminder to board for less old entries."""
Registration.objects.exclude(
status__in=(Registration.STATUS_COMPLETED, Registration.STATUS_REJECTED)
).filter(
payment=None,
updated_at__lt=timezone.now() - timedelta(days=30),
created_at__lt=timezone.now() - timedelta(days=90),
).delete()
Renewal.objects.filter(
Renewal.objects.exclude(
status__in=(Renewal.STATUS_COMPLETED, Renewal.STATUS_REJECTED)
).filter(
payment=None,
updated_at__lt=timezone.now() - timedelta(days=30),
created_at__lt=timezone.now() - timedelta(days=90),
).delete()

for registration in Registration.objects.filter(
updated_at__lt=timezone.now() - timedelta(days=30)
):
# send email
for registration in Registration.objects.exclude(
status__in=(Registration.STATUS_COMPLETED, Registration.STATUS_REJECTED)
).filter(payment=None, updated_at__lt=timezone.now() - timedelta(days=30)):
emails.send_reminder_open_registration(registration)
registration.updated_at = timezone.now()
registration.save()

0 comments on commit 95d00e7

Please sign in to comment.