fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Librarian 1.8
[wolnelektury.git]
/
src
/
messaging
/
models.py
diff --git
a/src/messaging/models.py
b/src/messaging/models.py
index
b7a87b3
..
c929228
100644
(file)
--- a/
src/messaging/models.py
+++ b/
src/messaging/models.py
@@
-43,7
+43,8
@@
class EmailTemplate(models.Model):
contacts = contacts.exclude(emailsent__template=self)
for contact in contacts:
contacts = contacts.exclude(emailsent__template=self)
for contact in contacts:
- self.send(contact, verbose=verbose, dry_run=dry_run)
+ if not contact.is_annoyed:
+ self.send(contact, verbose=verbose, dry_run=dry_run)
def get_state(self, time=None, test=False):
for s in states:
def get_state(self, time=None, test=False):
for s in states:
@@
-115,6
+116,11
@@
class Contact(models.Model):
self.key = get_random_hash(self.email)
super().save(*args, **kwargs)
self.key = get_random_hash(self.email)
super().save(*args, **kwargs)
+ @property
+ def is_annoyed(self):
+ cutoff = now() - timedelta(settings.MESSAGING_MIN_DAYS)
+ return self.emailsent_set.filter(timestamp__gte=cutoff).exists()
+
def get_optout_url(self):
return reverse('messaging_optout', args=[self.key])
def get_optout_url(self):
return reverse('messaging_optout', args=[self.key])