X-Git-Url: https://git.mdrn.pl/cas.git/blobdiff_plain/21765da5d86c0c20f785523ac5839c14e89f1237..3a5b7046f78122c77861a2cfce46fa3b5e248f8f:/src/emails/models.py diff --git a/src/emails/models.py b/src/emails/models.py index b666162..5375a7c 100644 --- a/src/emails/models.py +++ b/src/emails/models.py @@ -1,5 +1,5 @@ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from . import BASE_DOMAINS @@ -30,3 +30,14 @@ class Alias(models.Model): def get_to_user(cls, user): lookups = ["{}@{}".format(user.username, domain) for domain in BASE_DOMAINS] return cls.objects.filter(destination__in=lookups) + + +class AliasUsage(models.Model): + alias = models.ForeignKey(Alias, models.CASCADE, _('alias')) + date = models.DateField(_('date'), auto_now_add=True) + count = models.PositiveSmallIntegerField(_('count')) + + class Meta: + unique_together = (('alias', 'date'),) + verbose_name = _('alias usage') + verbose_name_plural = _('alias usage')