Add migration for new instrument type population
This commit is contained in:
parent
3e82389299
commit
885d9d4f88
|
|
@ -0,0 +1,37 @@
|
|||
# Generated by Django 2.2.24 on 2021-11-01 10:08
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from basicknowledge.models import LANGUAGE_COMMUNICATION, SOCIETY
|
||||
from core.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def create_new_types(apps, schema_editor):
|
||||
InstrumentType = apps.get_model('basicknowledge', 'InstrumentType')
|
||||
language_communication_types = [
|
||||
'Analyse', 'Argumentation', 'Beschreibung', 'Grafiken', 'Interview',
|
||||
'Kommunikation', 'Korrespondenz', 'Orthografie', 'Präsentation',
|
||||
'Struktur', 'Umfrage', 'Zusammenfassung'
|
||||
]
|
||||
society_types = [
|
||||
'Ethik', 'Identität und Sozialisation', 'Kultur', 'Ökologie',
|
||||
'Politik', 'Recht', 'Technologie', 'Wirtschaft'
|
||||
]
|
||||
|
||||
for type_name in language_communication_types:
|
||||
obj, created = InstrumentType.objects.get_or_create(name=type_name, category=LANGUAGE_COMMUNICATION)
|
||||
|
||||
for type_name in society_types:
|
||||
obj, created = InstrumentType.objects.get_or_create(name=type_name, category=SOCIETY)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('basicknowledge', '0011_auto_20211031_1144'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_new_types, migrations.RunPython.noop)
|
||||
]
|
||||
Loading…
Reference in New Issue