chore: migrate all VV learning units

so that their self evaluation pages show the ask for mentor feedback stuff
This commit is contained in:
Livio Bieri 2024-02-12 22:13:14 +01:00
parent 20bd103ab3
commit 1540e9d62a
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
# Generated by Django 3.2.20 on 2024-02-12 15:19
from django.db import migrations
VV_COURSE_IDS_WITH_MENTOR_FEEDBACK = [
-4, # vv-de
-10, # vv-fr
-11, # vv-it
]
def is_learning_unit_in_vv_course(learning_unit):
return learning_unit.course_category.course_id in VV_COURSE_IDS_WITH_MENTOR_FEEDBACK
def mutate_data(apps, schema_editor):
"""
Enable feedback for learning units in VV courses, this means that on the self-assessment page
of the learning unit, the user can request feedback from the mentor.
"""
LearningUnit = apps.get_model("learnpath", "LearningUnit") # noqa
for learning_unit in LearningUnit.objects.all():
if is_learning_unit_in_vv_course(learning_unit):
learning_unit.feedback_user = "MENTOR_FEEDBACK"
learning_unit.save()
def rollback_data(apps, schema_editor):
"""
Disable feedback for learning units in VV courses, this means that on the self-assessment page
of the learning unit, the user can not request feedback from the mentor. -> Default behaviour.
"""
LearningUnit = apps.get_model("learnpath", "LearningUnit") # noqa
for learning_unit in LearningUnit.objects.all():
if is_learning_unit_in_vv_course(learning_unit):
learning_unit.feedback_user = "NO_FEEDBACK"
learning_unit.save()
class Migration(migrations.Migration):
dependencies = [
("learnpath", "0014_alter_learningunit_feedback_user"),
]
operations = [
migrations.RunPython(mutate_data, rollback_data),
]