From 710a85c850acb492e5ce9072dec6bc7a00c3ab61 Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Tue, 7 Nov 2023 15:05:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Set=20donor=20subscriber=20to=20nul?= =?UTF-8?q?l=20when=20newsletter=20unsubscribe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fragdenstaat_de/fds_donation/apps.py | 4 ++++ fragdenstaat_de/fds_donation/listeners.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/fragdenstaat_de/fds_donation/apps.py b/fragdenstaat_de/fds_donation/apps.py index 121558c13..61edd745a 100644 --- a/fragdenstaat_de/fds_donation/apps.py +++ b/fragdenstaat_de/fds_donation/apps.py @@ -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" @@ -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, @@ -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 diff --git a/fragdenstaat_de/fds_donation/listeners.py b/fragdenstaat_de/fds_donation/listeners.py index 0d7ac679e..88ea3d285 100644 --- a/fragdenstaat_de/fds_donation/listeners.py +++ b/fragdenstaat_de/fds_donation/listeners.py @@ -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 @@ -171,3 +173,7 @@ def export_user_data(user): ] ), ) + + +def remove_newsletter_subscriber(sender: Subscriber, **kwargs): + Donor.objects.filter(subscriber=sender).update(subscriber=None)