Make verse numbers, footnote anchors, themes, dynamic inserts unselectable. Fixes...
[wolnelektury.git] / src / newsletter / models.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 import hashlib
5
6 from django.db.models import Model, EmailField, DateTimeField, BooleanField
7 from django.utils.translation import ugettext_lazy as _
8 from django.conf import settings
9
10
11 class Subscription(Model):
12     email = EmailField(verbose_name=_('email address'), unique=True)
13     active = BooleanField(default=True, verbose_name=_('active'))
14     created_at = DateTimeField(auto_now_add=True)
15     last_modified = DateTimeField(auto_now=True)
16
17     class Meta:
18         verbose_name = _('subscription')
19         verbose_name_plural = _('subscriptions')
20
21     def __str__(self):
22         return self.email
23
24     def hashcode(self):
25         return hashlib.sha224(self.email + settings.SECRET_KEY).hexdigest()[:30]