From 657ac5c975f427f8365120648cc025c527b3a849 Mon Sep 17 00:00:00 2001 From: Amit Upreti Date: Mon, 10 Apr 2023 11:50:02 -0400 Subject: [PATCH] add migration file --- .../training/migrations/0001_initial.py | 129 ++++++++++++++++++ .../0056_alter_trainingtype_required_field.py | 21 +++ 2 files changed, 150 insertions(+) create mode 100644 physionet-django/training/migrations/0001_initial.py create mode 100644 physionet-django/user/migrations/0056_alter_trainingtype_required_field.py diff --git a/physionet-django/training/migrations/0001_initial.py b/physionet-django/training/migrations/0001_initial.py new file mode 100644 index 0000000000..5ef675ddc1 --- /dev/null +++ b/physionet-django/training/migrations/0001_initial.py @@ -0,0 +1,129 @@ +# Generated by Django 4.1.7 on 2023-04-10 15:27 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import project.modelcomponents.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('user', '0056_alter_trainingtype_required_field'), + ] + + operations = [ + migrations.CreateModel( + name='Course', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('version', models.FloatField(default=1.0)), + ('training_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, + related_name='courses', to='user.trainingtype')), + ], + options={ + 'default_permissions': ('change',), + 'unique_together': {('training_type', 'version')}, + }, + ), + migrations.CreateModel( + name='CourseProgress', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.CharField(choices=[('IP', 'In Progress'), ('C', 'Completed')], default='IP', + max_length=2)), + ('started_datetime', models.DateTimeField(auto_now_add=True)), + ('completed_datetime', models.DateTimeField(auto_now=True)), + ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='training.course')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'unique_together': {('user', 'course')}, + }, + ), + migrations.CreateModel( + name='Module', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('order', models.PositiveIntegerField()), + ('description', project.modelcomponents.fields.SafeHTMLField()), + ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='modules', + to='training.course')), + ], + options={ + 'unique_together': {('course', 'order')}, + }, + ), + migrations.CreateModel( + name='Quiz', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('question', project.modelcomponents.fields.SafeHTMLField()), + ('order', models.PositiveIntegerField()), + ('module', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quizzes', + to='training.module')), + ], + ), + migrations.CreateModel( + name='QuizChoice', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('body', models.TextField()), + ('is_correct', models.BooleanField(default=False, verbose_name='Correct Choice?')), + ('quiz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', + to='training.quiz')), + ], + ), + migrations.CreateModel( + name='ModuleProgress', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.CharField(choices=[('IP', 'In Progress'), ('C', 'Completed')], default='IP', + max_length=2)), + ('last_completed_order', models.PositiveIntegerField(default=0, null=True)), + ('started_datetime', models.DateTimeField(blank=True, null=True)), + ('updated_datetime', models.DateTimeField(auto_now=True)), + ('course_progress', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, + related_name='module_progresses', to='training.courseprogress')), + ('module', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='training.module')), + ], + ), + migrations.CreateModel( + name='ContentBlock', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('body', project.modelcomponents.fields.SafeHTMLField()), + ('order', models.PositiveIntegerField()), + ('module', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contents', + to='training.module')), + ], + ), + migrations.CreateModel( + name='CompletedQuiz', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('completed_at', models.DateTimeField(blank=True, null=True)), + ('module_progress', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, + related_name='completed_quizzes', to='training.moduleprogress')), + ('quiz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='training.quiz')), + ], + ), + migrations.CreateModel( + name='CompletedContent', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('completed_at', models.DateTimeField(blank=True, null=True)), + ('content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, + to='training.contentblock')), + ('module_progress', models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name='completed_contents', + to='training.moduleprogress') + ), + ], + ), + ] diff --git a/physionet-django/user/migrations/0056_alter_trainingtype_required_field.py b/physionet-django/user/migrations/0056_alter_trainingtype_required_field.py new file mode 100644 index 0000000000..1328047fe3 --- /dev/null +++ b/physionet-django/user/migrations/0056_alter_trainingtype_required_field.py @@ -0,0 +1,21 @@ +# Generated by Django 4.1.5 on 2023-02-18 02:12 + +from django.db import migrations, models +import user.enums + + +class Migration(migrations.Migration): + + dependencies = [ + ('user', '0055_auto_20230330_1723'), + ] + + operations = [ + migrations.AlterField( + model_name='trainingtype', + name='required_field', + field=models.PositiveSmallIntegerField( + choices=[(0, 'DOCUMENT'), (1, 'URL'), (2, 'PLATFORM')], + default=user.enums.RequiredField['DOCUMENT']), + ), + ]