Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Set donor subscriber to null when newsletter unsubscribe #433

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)