summaryrefslogtreecommitdiff
path: root/archaeological_finds/migrations/0049_auto_20181210_1518.py
blob: 28f790ab0fc3a485e463352f0dfc4cb1e35a9f8b (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-12-10 15:18
from __future__ import unicode_literals

from django.db import migrations, models


def migrate_treatment_types(apps, schema):
    TreatmentType = apps.get_model('archaeological_finds', 'TreatmentType')
    q = TreatmentType.objects.filter(txt_idx="loan")
    if q.count():
        loan = q.all()[0]
        loan.change_current_location = True
        loan.save()
    q = TreatmentType.objects.filter(txt_idx="loan-return")
    if q.count():
        loan_r = q.all()[0]
        loan_r.restore_reference_location = True
        loan_r.save()
    q = TreatmentType.objects.filter(txt_idx="packaging")
    if q.count():
        packaging = q.all()[0]
        packaging.change_reference_location = True
        packaging.change_current_location = True
        packaging.save()
    q = TreatmentType.objects.filter(txt_idx="virtual-reassembly")
    if q.count():
        v = q.all()[0]
        v.upstream_is_many = False
        v.save()
    q = TreatmentType.objects.filter(txt_idx="virtual_group")
    if q.count():
        v = q.all()[0]
        v.upstream_is_many = False
        v.save()
    for t in TreatmentType.objects.all():
        t.txt_idx = t.txt_idx.replace("_", "-")
        t.save()


class Migration(migrations.Migration):

    dependencies = [
        ('archaeological_finds', '0048_auto_20181203_1746'),
    ]

    operations = [
        migrations.AddField(
            model_name='treatmenttype',
            name='change_current_location',
            field=models.BooleanField(default=False, help_text='The treatment change the current location.', verbose_name='Change current location'),
        ),
        migrations.AddField(
            model_name='treatmenttype',
            name='change_reference_location',
            field=models.BooleanField(default=False, help_text='The treatment change the reference location.', verbose_name='Change reference location'),
        ),
        migrations.AddField(
            model_name='treatmenttype',
            name='restore_reference_location',
            field=models.BooleanField(default=False, help_text='The treatment change restore reference location to the current location.', verbose_name='Restore the reference location'),
        ),
        migrations.RunPython(migrate_treatment_types)
    ]