Skip to content

Commit

Permalink
✨ Set donor subscriber to null when newsletter unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
pajowu authored and stefanw committed Nov 9, 2023
1 parent b4b3cf1 commit 710a85c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fragdenstaat_de/fds_donation/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _

from fragdenstaat_de.fds_newsletter import unsubscribed


class FdsDonationConfig(AppConfig):
name = "fragdenstaat_de.fds_donation"
Expand All @@ -24,6 +26,7 @@ def ready(self):
export_user_data,
merge_user,
payment_status_changed,
remove_newsletter_subscriber,
sepa_payment_processing,
subscription_was_canceled,
user_email_changed,
Expand All @@ -35,6 +38,7 @@ def ready(self):
account_canceled.connect(cancel_user)
account_email_changed.connect(user_email_changed)
account_merged.connect(merge_user)
unsubscribed.connect(remove_newsletter_subscriber)
registry.register(export_user_data)

from froide.account.menu import MenuItem, menu_registry
Expand Down
6 changes: 6 additions & 0 deletions fragdenstaat_de/fds_donation/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.db import transaction
from django.utils import timezone

from fragdenstaat_de.fds_newsletter.models import Subscriber

from froide_payment.models import PaymentStatus

from .models import Donation, Donor
Expand Down Expand Up @@ -171,3 +173,7 @@ def export_user_data(user):
]
),
)


def remove_newsletter_subscriber(sender: Subscriber, **kwargs):
Donor.objects.filter(subscriber=sender).update(subscriber=None)

0 comments on commit 710a85c

Please sign in to comment.