diff --git a/passbook/core/migrations/0003_invite.py b/passbook/core/migrations/0003_invite.py new file mode 100644 index 000000000..42379d5b4 --- /dev/null +++ b/passbook/core/migrations/0003_invite.py @@ -0,0 +1,30 @@ +# Generated by Django 2.1.4 on 2018-12-10 12:13 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('passbook_core', '0002_auto_20181210_1011'), + ] + + operations = [ + migrations.CreateModel( + name='Invite', + fields=[ + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('expires', models.DateTimeField(blank=True, default=None, null=True)), + ('fixed_username', models.TextField(blank=True, default=None)), + ('fixed_email', models.TextField(blank=True, default=None)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Invite', + 'verbose_name_plural': 'Invites', + }, + ), + ] diff --git a/passbook/core/models.py b/passbook/core/models.py index d86992226..adabcc6ec 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -249,3 +249,19 @@ class DebugRule(Rule): verbose_name = _('Debug Rule') verbose_name_plural = _('Debug Rules') + +class Invite(UUIDModel): + """Single-use invite link""" + + created_by = models.ForeignKey('User', on_delete=models.CASCADE) + expires = models.DateTimeField(default=None, blank=True, null=True) + fixed_username = models.TextField(blank=True, default=None) + fixed_email = models.TextField(blank=True, default=None) + + def __str__(self): + return "Invite %s created by %s" % (self.uuid, self.created_by) + + class Meta: + + verbose_name = _('Invite') + verbose_name_plural = _('Invites')