1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-26 05:42:20 +00:00
plateforme-corres2math/apps/participation/migrations/0006_phase.py
2020-10-20 14:35:04 +02:00

62 lines
1.9 KiB
Python

# Generated by Django 3.1.1 on 2020-10-20 10:39
from django.db import migrations, models
import django.utils.timezone
def register_phases(apps, schema_editor):
"""
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, schema_editor):
"""
Drop all phases in order to unapply this migration.
"""
Phase = apps.get_model("participation", "phase")
Phase.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('participation', '0005_participation_valid'),
]
operations = [
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.RunPython(
register_phases,
reverse_phase_registering,
),
]