mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
# Generated by Django 2.2.10 on 2021-03-10 09:05
|
|
|
|
from django.db import migrations
|
|
|
|
from .utils.question_sets import port_question
|
|
|
|
|
|
def migrate_forward(apps, schema_editor):
|
|
# Make question
|
|
Theme = apps.get_model('people', 'Theme')
|
|
theme_question = port_question(
|
|
apps, 'Research theme affiliation',
|
|
Theme.objects.all().values_list('name', flat=True),
|
|
is_multiple_choice=True)
|
|
|
|
PersonAnswerSet = apps.get_model('people', 'PersonAnswerSet')
|
|
for answerset in PersonAnswerSet.objects.all():
|
|
for theme in answerset.themes.all():
|
|
answerset.question_answers.add(
|
|
theme_question.answers.get(text=theme.name)
|
|
)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('people', '0043_organisationanswerset_is_partner_organisation'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(migrate_forward),
|
|
migrations.RemoveField(
|
|
model_name='personanswerset',
|
|
name='themes',
|
|
),
|
|
migrations.DeleteModel(
|
|
name='Theme',
|
|
),
|
|
]
|