diff --git a/self_registration/main/management/__init__.py b/self_registration/main/management/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/self_registration/main/management/commands/__init__.py b/self_registration/main/management/commands/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/self_registration/main/management/commands/delete_expired_subjects.py b/self_registration/main/management/commands/delete_expired_subjects.py
new file mode 100644
index 0000000000000000000000000000000000000000..f733deb62f2b6f071f59434a1462547b2cd91533
--- /dev/null
+++ b/self_registration/main/management/commands/delete_expired_subjects.py
@@ -0,0 +1,45 @@
+# (c) 2020 MPIB ,
+#
+# This file is part of castellum-self-registration.
+#
+# castellum-self-registration is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+#
+# Castellum is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with Castellum. If not, see
+# .
+
+from django.conf import settings
+from django.core.management.base import BaseCommand
+from django.utils import timezone
+
+from self_registration.main.models import SelfRegisteredSubject
+
+
+def delete_expired_subjects():
+ return SelfRegisteredSubject.objects.filter(
+ confirmed=False,
+ created_at__lte=timezone.now()-settings.SUBJECT_EXPIRATION_PERIOD
+ ).delete()
+
+
+class Command(BaseCommand):
+ help = 'Delete expired self-registered subjects.'
+
+ def handle(self, *args, **options):
+ count, _ = delete_expired_subjects()
+ if options['verbosity'] > 0:
+ self.stdout.write(
+ "{count} self-registered subjects were deleted, as they had not been confirmed "
+ "within {period} days.".format(
+ count=count,
+ period=settings.SUBJECT_EXPIRATION_PERIOD.days
+ )
+ )
diff --git a/self_registration/main/migrations/0002_email_confirmation.py b/self_registration/main/migrations/0002_email_confirmation.py
new file mode 100644
index 0000000000000000000000000000000000000000..cd858c56c10287ca0fa97d68f21f0fcdc5764b7a
--- /dev/null
+++ b/self_registration/main/migrations/0002_email_confirmation.py
@@ -0,0 +1,31 @@
+# Generated by Django 3.2.7 on 2021-09-13 09:43
+
+from django.db import migrations, models
+import django.utils.timezone
+import uuid
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('main', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='selfregisteredsubject',
+ name='confirmed',
+ field=models.BooleanField(default=False, verbose_name='Confirmed'),
+ ),
+ migrations.AddField(
+ model_name='selfregisteredsubject',
+ name='created_at',
+ field=models.DateField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Created at'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='selfregisteredsubject',
+ name='verification_token',
+ field=models.UUIDField(default=uuid.uuid4, verbose_name='Token'),
+ ),
+ ]
diff --git a/self_registration/main/models.py b/self_registration/main/models.py
index 882797f4279e2df8aa811f0133ab3011558b5e8d..61aaed8c7aa3f2a99762f2321c11897402a87e24 100644
--- a/self_registration/main/models.py
+++ b/self_registration/main/models.py
@@ -16,6 +16,7 @@
# License along with Castellum. If not, see
# .
+import uuid
from django.db import models
from django.utils.translation import gettext_lazy as _
@@ -37,3 +38,10 @@ class SelfRegisteredSubject(models.Model):
email = models.EmailField(_('Email'), max_length=128, blank=True)
phone_number = PhoneNumberField(_('Phone number'), max_length=32, blank=True)
date_of_birth = DateField(_('Date of birth'), blank=True, null=True)
+ confirmed = models.BooleanField(_('Confirmed'), default=False)
+ verification_token = models.UUIDField(_('Token'), default=uuid.uuid4)
+ created_at = models.DateField(_('Created at'), auto_now_add=True)
+
+ @property
+ def full_name(self):
+ return " ".join(filter(None, [self.first_name, self.last_name]))
diff --git a/self_registration/main/templates/base.html b/self_registration/main/templates/base.html
index 9f020ca5aafaf78ba31fb10ea151885a8d4c15fc..ba8380929136da74201545f2d91762d5bfa2715d 100644
--- a/self_registration/main/templates/base.html
+++ b/self_registration/main/templates/base.html
@@ -31,7 +31,6 @@
-
{% block extra_scripts %}{% endblock %}