plateforme-tfjm2/apps/participation/migrations/0001_initial.py

139 lines
6.1 KiB
Python

# Generated by Django 3.1.3 on 2020-11-04 12:05
import django.core.validators
from django.db import migrations, models
import django.utils.timezone
def register_phases(apps, _):
"""
Import the different phases of the action
"""
Phase = apps.get_model("participation", "phase")
Phase.objects.get_or_create(
phase_number=1,
description="Soumission des vidéos",
)
Phase.objects.get_or_create(
phase_number=2,
description="Phase de questions",
)
Phase.objects.get_or_create(
phase_number=3,
description="Phase d'échanges entre les équipes",
)
Phase.objects.get_or_create(
phase_number=4,
description="Synthèse de l'échange",
)
def reverse_phase_registering(apps, _): # pragma: no cover
"""
Drop all phases in order to unapply this migration.
"""
Phase = apps.get_model("participation", "phase")
Phase.objects.all().delete()
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Participation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('problem', models.IntegerField(choices=[(1, 'Problem #1'), (2, 'Problem #2'), (3, 'Problem #3')], default=None, null=True, verbose_name='problem number')),
('valid', models.BooleanField(default=None, help_text='The video got the validation of the administrators.', null=True, verbose_name='valid')),
],
options={
'verbose_name': 'participation',
'verbose_name_plural': 'participations',
},
),
migrations.CreateModel(
name='Phase',
fields=[
('phase_number', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='phase number')),
('description', models.CharField(max_length=255, verbose_name='phase description')),
('start', models.DateTimeField(default=django.utils.timezone.now, verbose_name='start date of the given phase')),
('end', models.DateTimeField(default=django.utils.timezone.now, verbose_name='end date of the given phase')),
],
options={
'verbose_name': 'phase',
'verbose_name_plural': 'phases',
},
),
migrations.CreateModel(
name='Question',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('question', models.TextField(verbose_name='question')),
],
),
migrations.CreateModel(
name='Team',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True, verbose_name='name')),
('trigram', models.CharField(help_text='The trigram must be composed of three uppercase letters.', max_length=3, unique=True, validators=[django.core.validators.RegexValidator('[A-Z]{3}')], verbose_name='trigram')),
('access_code', models.CharField(help_text='The access code let other people to join the team.', max_length=6, verbose_name='access code')),
('grant_animath_access_videos', models.BooleanField(default=False, help_text='Give the authorisation to publish the video on the main website to promote the action.', verbose_name='Grant Animath to publish my video')),
],
options={
'verbose_name': 'team',
'verbose_name_plural': 'teams',
},
),
migrations.CreateModel(
name='Video',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('link', models.URLField(help_text='The full video link.', verbose_name='link')),
('valid', models.BooleanField(default=None, help_text='The video got the validation of the administrators.', null=True, verbose_name='valid')),
],
options={
'verbose_name': 'video',
'verbose_name_plural': 'videos',
},
),
migrations.AddIndex(
model_name='team',
index=models.Index(fields=['trigram'], name='participati_trigram_239255_idx'),
),
migrations.AddField(
model_name='question',
name='participation',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='participation.participation', verbose_name='participation'),
),
migrations.AddField(
model_name='participation',
name='received_participation',
field=models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='sent_participation', to='participation.participation', verbose_name='received participation'),
),
migrations.AddField(
model_name='participation',
name='solution',
field=models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='participation_solution', to='participation.video', verbose_name='solution video'),
),
migrations.AddField(
model_name='participation',
name='synthesis',
field=models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='participation_synthesis', to='participation.video', verbose_name='synthesis video'),
),
migrations.AddField(
model_name='participation',
name='team',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='participation.team', verbose_name='team'),
),
migrations.RunPython(
register_phases,
reverse_code=reverse_phase_registering,
)
]