X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e852900e42eb0bde98daf7070d84816e44c3308e..1b80c204be885588f7cbe95610e3677f2f886801:/src/messaging/models.py diff --git a/src/messaging/models.py b/src/messaging/models.py index 8ef6c4c0f..b7a87b35d 100644 --- a/src/messaging/models.py +++ b/src/messaging/models.py @@ -4,6 +4,7 @@ from django.core.mail import send_mail from django.db import models from django.template import Template, Context from django.urls import reverse +from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ from sentry_sdk import capture_exception from catalogue.utils import get_random_hash @@ -40,7 +41,7 @@ class EmailTemplate(models.Model): state = self.get_state(time=time) contacts = state.get_contacts() - contacts = contacts.exclude(emailsent_set__template=self) + contacts = contacts.exclude(emailsent__template=self) for contact in contacts: self.send(contact, verbose=verbose, dry_run=dry_run) @@ -127,7 +128,9 @@ class Contact(models.Model): if not created: obj.ascend(level, since, expires_at) - def ascend(self, level, since, expires_at=None): + def ascend(self, level, since=None, expires_at=None): + if since is None: + since = now() if level < self.level: return if level == self.level: