X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/8044f0dceec591bcc77579cf7cf4af843cf5c5fa..243ac5a586da9e5abb87698306794b6cc173ded1:/src/messaging/models.py?ds=inline diff --git a/src/messaging/models.py b/src/messaging/models.py index fccd64776..e1b26a8a0 100644 --- a/src/messaging/models.py +++ b/src/messaging/models.py @@ -6,7 +6,7 @@ from django.db import models from django.template import Template, Context from django.urls import reverse from django.utils.timezone import now, get_current_timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from sentry_sdk import capture_exception from catalogue.utils import get_random_hash from .states import Level, states @@ -112,6 +112,7 @@ class Contact(models.Model): (Level.TRIED, _('Would-be donor')), (Level.SINGLE, _('One-time donor')), (Level.RECURRING, _('Recurring donor')), + (Level.MANUAL_MEMBER, _('Manually set as member')), (Level.OPT_OUT, _('Opt out')), ]) since = models.DateTimeField() @@ -163,6 +164,19 @@ class Contact(models.Model): self.expires_at = expires_at self.save() + @classmethod + def reset(cls, email): + cls.objects.filter(email=email).delete() + Schedule = apps.get_model('club', 'Schedule') + Membership = apps.get_model('club', 'Membership') + for schedule in Schedule.objects.filter(email=email): + schedule.update_contact() + for membership in Membership.objects.filter(manual=True, user__email=email): + membership.update_contact() + + def wl_optout_url(self): + return 'https://wolnelektury.pl' + self.get_optout_url() + class EmailSent(models.Model): template = models.ForeignKey(EmailTemplate, models.CASCADE)