From 700710d1aa59af7316ba9694711bfca051925677 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 21 Oct 2020 10:42:49 +0200 Subject: [PATCH] Export contacts with optout addresses. --- src/messaging/admin.py | 5 ++++- src/messaging/models.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/messaging/admin.py b/src/messaging/admin.py index 615e1e861..da58b3a53 100644 --- a/src/messaging/admin.py +++ b/src/messaging/admin.py @@ -71,7 +71,10 @@ class ContactAdmin(admin.ModelAdmin): list_display = ['email', 'level', 'since', 'expires_at'] search_fields = ['email'] date_hierarchy = 'since' - actions = [export_as_csv_action(fields=['id', 'email', 'get_level_display', 'since', 'expires_at'])] + actions = [ + export_as_csv_action(fields=['id', 'email', 'get_level_display', 'since', 'expires_at']), + export_as_csv_action('Eksport dla PHPList', fields=['email', 'wl_optout_url']) + ] admin.site.register(models.Contact, ContactAdmin) diff --git a/src/messaging/models.py b/src/messaging/models.py index fccd64776..d598fc852 100644 --- a/src/messaging/models.py +++ b/src/messaging/models.py @@ -163,6 +163,9 @@ class Contact(models.Model): self.expires_at = expires_at self.save() + def wl_optout_url(self): + return 'https://wolnelektury.pl' + self.get_optout_url() + class EmailSent(models.Model): template = models.ForeignKey(EmailTemplate, models.CASCADE) -- 2.20.1