mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-21 14:38:21 +02:00
Setup models and database
This commit is contained in:
70
apps/registration/migrations/0001_initial.py
Normal file
70
apps/registration/migrations/0001_initial.py
Normal file
@ -0,0 +1,70 @@
|
||||
# Generated by Django 3.1.1 on 2020-09-21 15:51
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('participation', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Registration',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('give_contact_to_animath', models.BooleanField(default=False, verbose_name='Grant Animath to contact me in the future about other actions')),
|
||||
('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_registration.registration_set+', to='contenttypes.contenttype')),
|
||||
('team', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='participation.team', verbose_name='team')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='user')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'registration',
|
||||
'verbose_name_plural': 'registrations',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AdminRegistration',
|
||||
fields=[
|
||||
('registration_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registration.registration')),
|
||||
('role', models.TextField(verbose_name='role of the administrator')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'admin registration',
|
||||
'verbose_name_plural': 'admin registrations',
|
||||
},
|
||||
bases=('registration.registration',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CoachRegistration',
|
||||
fields=[
|
||||
('registration_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registration.registration')),
|
||||
('professional_activity', models.TextField(verbose_name='professional activity')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'coach registration',
|
||||
'verbose_name_plural': 'coach registrations',
|
||||
},
|
||||
bases=('registration.registration',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StudentRegistration',
|
||||
fields=[
|
||||
('registration_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registration.registration')),
|
||||
('student_class', models.IntegerField(choices=[(12, '12th grade'), (11, '11th grade'), (10, '10th grade or lower')], verbose_name='student class')),
|
||||
('school', models.CharField(max_length=255, verbose_name='school')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'student registration',
|
||||
'verbose_name_plural': 'student registrations',
|
||||
},
|
||||
bases=('registration.registration',),
|
||||
),
|
||||
]
|
@ -1,3 +1,88 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Registration(PolymorphicModel):
|
||||
user = models.OneToOneField(
|
||||
"auth.User",
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_("user"),
|
||||
)
|
||||
|
||||
team = models.ForeignKey(
|
||||
"participation.Team",
|
||||
on_delete=models.PROTECT,
|
||||
null=True,
|
||||
default=None,
|
||||
verbose_name=_("team"),
|
||||
)
|
||||
|
||||
give_contact_to_animath = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("Grant Animath to contact me in the future about other actions"),
|
||||
)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def __str__(self):
|
||||
return _("registration of {first_name} {last_name}")\
|
||||
.format(first_name=self.user.first_name, last_name=self.user.last_name)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("registration")
|
||||
verbose_name_plural = _("registrations")
|
||||
|
||||
|
||||
class StudentRegistration(Registration):
|
||||
student_class = models.IntegerField(
|
||||
choices=[
|
||||
(12, _("12th grade")),
|
||||
(11, _("11th grade")),
|
||||
(10, _("10th grade or lower")),
|
||||
],
|
||||
verbose_name=_("student class"),
|
||||
)
|
||||
|
||||
school = models.CharField(
|
||||
max_length=255,
|
||||
verbose_name=_("school"),
|
||||
)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return _("student")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("student registration")
|
||||
verbose_name_plural = _("student registrations")
|
||||
|
||||
|
||||
class CoachRegistration(Registration):
|
||||
professional_activity = models.TextField(
|
||||
verbose_name=_("professional activity"),
|
||||
)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return _("coach")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("coach registration")
|
||||
verbose_name_plural = _("coach registrations")
|
||||
|
||||
|
||||
class AdminRegistration(Registration):
|
||||
role = models.TextField(
|
||||
verbose_name=_("role of the administrator"),
|
||||
)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return _("admin")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("admin registration")
|
||||
verbose_name_plural = _("admin registrations")
|
||||
|
Reference in New Issue
Block a user