okfde / fragdenstaat_de

Froide Theme for fragdenstaat.de
https://fragdenstaat.de
Other
121 stars 21 forks source link

✨ Set donor subscriber to null when newsletter unsubscribe #433

Closed pajowu closed 7 months ago

pajowu commented 8 months ago

Suggested code to run to cleanup old donors:

from django.utils import timezone
from datetime import timedelta
from fragdenstaat_de.fds_donation.models import Donor

now = timezone.now()
three_days_ago = now - timedelta(days=3)
donors = Donor.objects.filter(subscriber__unsubscribed__lt=three_days_ago)
donors.update(subscriber=None)
stefanw commented 8 months ago

Ideally, I'd try to move this into fds_donation, so fds_newsletter doesn't need to know about donations (the fds_newsletter/analytics.py was a mistake in that regard and we already have a different solution in place). Maybe using the unsubscribed signal of the newsletter system in fds_donation/apps.py. Then it also immediately disconnects instead of during the cleanup cycle.

pajowu commented 8 months ago

Sure, how about this solution?