From: Radek Czajka Date: Fri, 5 Apr 2019 21:04:43 +0000 (+0200) Subject: Add AliasUsage X-Git-Url: https://git.mdrn.pl/cas.git/commitdiff_plain/51dd34049b3c3ddae6da1664e6a4ca3b71e86675 Add AliasUsage --- diff --git a/src/emails/locale/pl/LC_MESSAGES/django.mo b/src/emails/locale/pl/LC_MESSAGES/django.mo index 2d00809..98cc0b8 100644 Binary files a/src/emails/locale/pl/LC_MESSAGES/django.mo and b/src/emails/locale/pl/LC_MESSAGES/django.mo differ diff --git a/src/emails/locale/pl/LC_MESSAGES/django.po b/src/emails/locale/pl/LC_MESSAGES/django.po index b8f4fd9..e125b13 100644 --- a/src/emails/locale/pl/LC_MESSAGES/django.po +++ b/src/emails/locale/pl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-04-05 14:46+0200\n" +"POT-Creation-Date: 2019-04-05 23:03+0200\n" "PO-Revision-Date: 2019-04-05 14:46+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -44,7 +44,7 @@ msgstr "Przekazuj wszystko" msgid "Do not forward e-mail marked as spam." msgstr "Nie przekazuj wiadomości oznaczonych jako spam." -#: models.py:17 +#: models.py:17 models.py:36 msgid "alias" msgstr "alias" @@ -52,18 +52,31 @@ msgstr "alias" msgid "aliases" msgstr "aliasy" -#: templates/emails/my_aliases.html:7 +#: models.py:37 +msgid "date" +msgstr "data" + +#: models.py:38 +msgid "count" +msgstr "liczba" + +#: models.py:42 models.py:43 +#| msgid "aliases" +msgid "alias usage" +msgstr "użycie aliasów" + +#: templates/emails/my_aliases.html:8 msgid "E-mail" msgstr "E-mail" -#: templates/emails/my_aliases.html:9 +#: templates/emails/my_aliases.html:14 msgid "Default addresses" msgstr "Domyślne adresy" -#: templates/emails/my_aliases.html:16 +#: templates/emails/my_aliases.html:21 msgid "Aliases" msgstr "Aliasy" -#: templates/emails/my_aliases.html:20 +#: templates/emails/my_aliases.html:25 msgid "E-mail forwarded to" msgstr "E-mail przekazywany na adres" diff --git a/src/emails/migrations/0003_aliasusage.py b/src/emails/migrations/0003_aliasusage.py new file mode 100644 index 0000000..8d5cb93 --- /dev/null +++ b/src/emails/migrations/0003_aliasusage.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2 on 2019-04-05 21:03 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('emails', '0002_alias_mode'), + ] + + operations = [ + migrations.CreateModel( + name='AliasUsage', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField(auto_now_add=True, verbose_name='date')), + ('count', models.PositiveSmallIntegerField(verbose_name='count')), + ('alias', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='alias', to='emails.Alias')), + ], + options={ + 'verbose_name': 'alias usage', + 'verbose_name_plural': 'alias usage', + 'unique_together': {('alias', 'date')}, + }, + ), + ] diff --git a/src/emails/models.py b/src/emails/models.py index b666162..e64e423 100644 --- a/src/emails/models.py +++ b/src/emails/models.py @@ -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')