summaryrefslogtreecommitdiff
path: root/archaeological_finds/migrations/0125_data_migration_communicability_functionalarea.py
blob: 3734e46d5c23e51e170b1f89d384720701984e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os

from django.db import migrations
from django.core.management import call_command


def load_data(apps, __):
    CommunicabilityType = apps.get_model("archaeological_finds", "communicabilitytype")
    if not CommunicabilityType.objects.count():
        migration = "0125_data_migration_communicability.json"
        json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + [migration])
        call_command("loaddata", json_path)

    FunctionalArea = apps.get_model("archaeological_finds", "functionalarea")
    if not FunctionalArea.objects.count():
        migration = "0125_data_migration_functionalarea.json"
        json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + [migration])
        call_command("loaddata", json_path)


class Migration(migrations.Migration):

    dependencies = [
        ('archaeological_finds', '0124_verbose_names'),
    ]

    operations = [
        migrations.RunPython(load_data)
    ]