diff --git a/self_registration/main/models.py b/self_registration/main/models.py
new file mode 100644
index 0000000000000000000000000000000000000000..810ea2d902f002c560f984a8e142ca60bf5d52b3
--- /dev/null
+++ b/self_registration/main/models.py
@@ -0,0 +1,37 @@
+# (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.db import models
+from django.utils.translation import gettext_lazy as _
+
+from self_registration.utils.fields import DateField
+from self_registration.utils.fields import PhoneNumberField
+
+
+class SelfRegisteredSubject(models.Model):
+ GENDER = [
+ ("f", _("female")),
+ ("m", _("male")),
+ ("*", _("diverse")),
+ ]
+
+ first_name = models.CharField(_('First name'), max_length=64)
+ last_name = models.CharField(_('Last name'), max_length=64)
+ gender = models.CharField(_('Gender'), max_length=1, choices=GENDER, blank=True)
+ email = models.EmailField(_('Email'), max_length=128, blank=True)
diff --git a/self_registration/main/views.py b/self_registration/main/views.py
new file mode 100644
index 0000000000000000000000000000000000000000..cef22ce89250b3cc569e22df5747740ed83c66b6
--- /dev/null
+++ b/self_registration/main/views.py
@@ -0,0 +1,37 @@
+# (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.contrib import messages
+from django.urls import reverse
+from django.views.generic import CreateView
+
+from self_registration.models import SelfRegisteredSubject
+
+
+class SelfRegisteredSubjectCreateView(CreateView):
+ model = SelfRegisteredSubject
+ template_name = 'subject_form.html'
+ fields = ['first_name', 'last_name', 'gender', 'date_of_birth', 'email', 'phone_number']
+
+ def get_success_url(self):
+ return reverse('subject-create')
+
+ def form_valid(self, form, *args):
+ messages.success(self.request, _('Data has been saved.'))
+ return super().form_valid(form, *args)
diff --git a/self_registration/settings/default.py b/self_registration/settings/default.py
index 9c26bd0498a8170553547199cd9d0989f8122f24..d97174612a3c661cbb121af60f18b9411f306f86 100644
--- a/self_registration/settings/default.py
+++ b/self_registration/settings/default.py
@@ -13,6 +13,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap4',
+ 'self_registration.main',
]
MIDDLEWARE = [
diff --git a/self_registration/urls.py b/self_registration/urls.py
index 1a14f30765935ab9685833a28214805e276d803d..d64f656c159da6cda8859833e54dc5bfe484fd5c 100644
--- a/self_registration/urls.py
+++ b/self_registration/urls.py
@@ -16,6 +16,9 @@ Including another URLconf
from django.contrib import admin
from django.urls import path
+from self_registration.views import SelfRegisteredSubjectCreateView
+
urlpatterns = [
path('admin/', admin.site.urls),
+ path('create/', SelfRegisteredSubjectCreateView.as_view(), name='subject-create'),
]
diff --git a/self_registration/utils/fields.py b/self_registration/utils/fields.py
new file mode 100644
index 0000000000000000000000000000000000000000..b32f469f995434bde9c9d772993ceb2f68c53cea
--- /dev/null
+++ b/self_registration/utils/fields.py
@@ -0,0 +1,36 @@
+# (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.db import models
+
+from phonenumber_field.modelfields import PhoneNumberField as _PhoneNumberField
+
+from .forms import DateField as DateFormField
+from .forms import PhoneNumberField as PhoneNumberFormField
+
+
+class DateField(models.DateField):
+ def formfield(self, **kwargs):
+ kwargs.setdefault('form_class', DateFormField)
+ return super().formfield(**kwargs)
+
+
+class PhoneNumberField(_PhoneNumberField):
+ def formfield(self, **kwargs):
+ kwargs.setdefault('form_class', PhoneNumberFormField)
+ return super().formfield(**kwargs)
diff --git a/self_registration/utils/forms.py b/self_registration/utils/forms.py
new file mode 100644
index 0000000000000000000000000000000000000000..d1458b08aa1fe4c236e47bc0ec7185e634c00b97
--- /dev/null
+++ b/self_registration/utils/forms.py
@@ -0,0 +1,56 @@
+# (c) 2018-2021
+# MPIB ,
+# MPI-CBS ,
+# MPIP
+#
+# This file is part of Castellum.
+#
+# Castellum 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 import forms
+from django.utils.translation import gettext_lazy as _
+
+from phonenumber_field.formfields import PhoneNumberField as _PhoneNumberFormField
+from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget
+
+
+class DateInput(forms.DateInput):
+ def __init__(self, attrs=None):
+ defaults = {
+ 'placeholder': _('yyyy-mm-dd, e.g. 2018-07-21'),
+ 'autocomplete': 'off',
+ 'type': 'date',
+ }
+ if attrs:
+ defaults.update(attrs)
+ super().__init__(format='%Y-%m-%d', attrs=defaults)
+
+
+class DateField(forms.DateField):
+ widget = DateInput
+
+
+class PhoneNumberWidget(PhoneNumberInternationalFallbackWidget):
+ def __init__(self, attrs=None):
+ defaults = {
+ 'placeholder': _('e.g. 030 123456'),
+ }
+ if attrs:
+ defaults.update(defaults)
+ super().__init__(attrs=defaults)
+
+
+class PhoneNumberField(_PhoneNumberFormField):
+ widget = PhoneNumberWidget