From c3c2c55aca6e646b48d890faded86be69b3cdff2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 4 Nov 2020 13:13:34 +0100 Subject: [PATCH] Squash migrations --- apps/logs/migrations/0001_initial.py | 4 +- apps/participation/migrations/0001_initial.py | 71 +++++++++++++++++-- .../0002_team_grant_animath_access_videos.py | 18 ----- .../migrations/0003_auto_20200927_1309.py | 28 -------- .../migrations/0004_auto_20200927_1322.py | 24 ------- .../migrations/0005_participation_valid.py | 18 ----- apps/participation/migrations/0006_phase.py | 61 ---------------- .../participation/migrations/0007_question.py | 22 ------ apps/registration/migrations/0001_initial.py | 34 +++++---- .../migrations/0002_auto_20200921_1948.py | 29 -------- .../0003_registration_email_confirmed.py | 18 ----- ...studentregistration_photo_authorization.py | 19 ----- 12 files changed, 87 insertions(+), 259 deletions(-) delete mode 100644 apps/participation/migrations/0002_team_grant_animath_access_videos.py delete mode 100644 apps/participation/migrations/0003_auto_20200927_1309.py delete mode 100644 apps/participation/migrations/0004_auto_20200927_1322.py delete mode 100644 apps/participation/migrations/0005_participation_valid.py delete mode 100644 apps/participation/migrations/0006_phase.py delete mode 100644 apps/participation/migrations/0007_question.py delete mode 100644 apps/registration/migrations/0002_auto_20200921_1948.py delete mode 100644 apps/registration/migrations/0003_registration_email_confirmed.py delete mode 100644 apps/registration/migrations/0004_studentregistration_photo_authorization.py diff --git a/apps/logs/migrations/0001_initial.py b/apps/logs/migrations/0001_initial.py index 82431ad..1e08d02 100644 --- a/apps/logs/migrations/0001_initial.py +++ b/apps/logs/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.1 on 2020-09-21 15:33 +# Generated by Django 3.1.3 on 2020-11-04 12:05 from django.conf import settings from django.db import migrations, models @@ -11,8 +11,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('contenttypes', '0002_remove_content_type_name'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('contenttypes', '0002_remove_content_type_name'), ] operations = [ diff --git a/apps/participation/migrations/0001_initial.py b/apps/participation/migrations/0001_initial.py index f1eea8d..903bf86 100644 --- a/apps/participation/migrations/0001_initial.py +++ b/apps/participation/migrations/0001_initial.py @@ -1,8 +1,39 @@ -# Generated by Django 3.1.1 on 2020-09-21 15:51 +# Generated by Django 3.1.3 on 2020-11-04 12:05 import django.core.validators from django.db import migrations, models -import django.db.models.deletion +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): @@ -18,12 +49,33 @@ class Migration(migrations.Migration): 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=[ @@ -31,6 +83,7 @@ class Migration(migrations.Migration): ('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', @@ -43,7 +96,6 @@ class Migration(migrations.Migration): ('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')), - ('participation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='participation.participation', verbose_name='participation')), ], options={ 'verbose_name': 'video', @@ -54,6 +106,11 @@ class Migration(migrations.Migration): 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', @@ -62,16 +119,20 @@ class Migration(migrations.Migration): migrations.AddField( model_name='participation', name='solution', - field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='participation.video', verbose_name='solution video'), + 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.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='participation.video', verbose_name='synthesis video'), + 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, + ) ] diff --git a/apps/participation/migrations/0002_team_grant_animath_access_videos.py b/apps/participation/migrations/0002_team_grant_animath_access_videos.py deleted file mode 100644 index 7832ade..0000000 --- a/apps/participation/migrations/0002_team_grant_animath_access_videos.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.1 on 2020-09-22 16:21 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('participation', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='team', - name='grant_animath_access_videos', - field=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'), - ), - ] diff --git a/apps/participation/migrations/0003_auto_20200927_1309.py b/apps/participation/migrations/0003_auto_20200927_1309.py deleted file mode 100644 index a914976..0000000 --- a/apps/participation/migrations/0003_auto_20200927_1309.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 3.1.1 on 2020-09-27 11:09 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('participation', '0002_team_grant_animath_access_videos'), - ] - - operations = [ - migrations.RemoveField( - model_name='video', - name='participation', - ), - migrations.AlterField( - model_name='participation', - name='solution', - field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='participation', to='participation.video', verbose_name='solution video'), - ), - migrations.AlterField( - model_name='participation', - name='synthesis', - field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='participation_synthesis', to='participation.video', verbose_name='synthesis video'), - ), - ] diff --git a/apps/participation/migrations/0004_auto_20200927_1322.py b/apps/participation/migrations/0004_auto_20200927_1322.py deleted file mode 100644 index ca5f9ae..0000000 --- a/apps/participation/migrations/0004_auto_20200927_1322.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 3.1.1 on 2020-09-27 11:22 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('participation', '0003_auto_20200927_1309'), - ] - - operations = [ - migrations.AlterField( - 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.AlterField( - 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'), - ), - ] diff --git a/apps/participation/migrations/0005_participation_valid.py b/apps/participation/migrations/0005_participation_valid.py deleted file mode 100644 index f22fc7d..0000000 --- a/apps/participation/migrations/0005_participation_valid.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.1 on 2020-10-11 13:58 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('participation', '0004_auto_20200927_1322'), - ] - - operations = [ - migrations.AddField( - model_name='participation', - name='valid', - field=models.BooleanField(default=None, help_text='The video got the validation of the administrators.', null=True, verbose_name='valid'), - ), - ] diff --git a/apps/participation/migrations/0006_phase.py b/apps/participation/migrations/0006_phase.py deleted file mode 100644 index e7b5212..0000000 --- a/apps/participation/migrations/0006_phase.py +++ /dev/null @@ -1,61 +0,0 @@ -# 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, _): # 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): - 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, - ), - ] diff --git a/apps/participation/migrations/0007_question.py b/apps/participation/migrations/0007_question.py deleted file mode 100644 index 814487f..0000000 --- a/apps/participation/migrations/0007_question.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 3.0.10 on 2020-10-31 13:36 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('participation', '0006_phase'), - ] - - operations = [ - 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')), - ('participation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='participation.Participation', verbose_name='participation')), - ], - ), - ] diff --git a/apps/registration/migrations/0001_initial.py b/apps/registration/migrations/0001_initial.py index 0ea8266..37baf8d 100644 --- a/apps/registration/migrations/0001_initial.py +++ b/apps/registration/migrations/0001_initial.py @@ -1,8 +1,9 @@ -# Generated by Django 3.1.1 on 2020-09-21 15:51 +# Generated by Django 3.1.3 on 2020-11-04 12:05 from django.conf import settings from django.db import migrations, models import django.db.models.deletion +import registration.models class Migration(migrations.Migration): @@ -11,8 +12,8 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('contenttypes', '0002_remove_content_type_name'), ('participation', '0001_initial'), + ('contenttypes', '0002_remove_content_type_name'), ] operations = [ @@ -21,8 +22,8 @@ class Migration(migrations.Migration): 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')), + ('email_confirmed', models.BooleanField(default=False, verbose_name='email confirmed')), ('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={ @@ -42,24 +43,14 @@ class Migration(migrations.Migration): }, 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')), + ('photo_authorization', models.FileField(blank=True, default='', upload_to=registration.models.get_random_filename, verbose_name='photo authorization')), + ('team', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='students', to='participation.team', verbose_name='team')), ], options={ 'verbose_name': 'student registration', @@ -67,4 +58,17 @@ class Migration(migrations.Migration): }, 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')), + ('team', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='coachs', to='participation.team', verbose_name='team')), + ], + options={ + 'verbose_name': 'coach registration', + 'verbose_name_plural': 'coach registrations', + }, + bases=('registration.registration',), + ), ] diff --git a/apps/registration/migrations/0002_auto_20200921_1948.py b/apps/registration/migrations/0002_auto_20200921_1948.py deleted file mode 100644 index 759bbac..0000000 --- a/apps/registration/migrations/0002_auto_20200921_1948.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 3.1.1 on 2020-09-21 17:48 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('participation', '0001_initial'), - ('registration', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='registration', - name='team', - ), - migrations.AddField( - model_name='coachregistration', - name='team', - field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='coachs', to='participation.team', verbose_name='team'), - ), - migrations.AddField( - model_name='studentregistration', - name='team', - field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='students', to='participation.team', verbose_name='team'), - ), - ] diff --git a/apps/registration/migrations/0003_registration_email_confirmed.py b/apps/registration/migrations/0003_registration_email_confirmed.py deleted file mode 100644 index a9cc7ae..0000000 --- a/apps/registration/migrations/0003_registration_email_confirmed.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.1 on 2020-09-22 16:56 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('registration', '0002_auto_20200921_1948'), - ] - - operations = [ - migrations.AddField( - model_name='registration', - name='email_confirmed', - field=models.BooleanField(default=False, verbose_name='email confirmed'), - ), - ] diff --git a/apps/registration/migrations/0004_studentregistration_photo_authorization.py b/apps/registration/migrations/0004_studentregistration_photo_authorization.py deleted file mode 100644 index c6477ee..0000000 --- a/apps/registration/migrations/0004_studentregistration_photo_authorization.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.1.1 on 2020-09-24 20:36 - -from django.db import migrations, models -import registration.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('registration', '0003_registration_email_confirmed'), - ] - - operations = [ - migrations.AddField( - model_name='studentregistration', - name='photo_authorization', - field=models.FileField(blank=True, default='', upload_to=registration.models.get_random_filename, verbose_name='photo authorization'), - ), - ]