0003_auto_20151202_1539.py
1.07 KB
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
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.db import migrations, models
from common.util import no_history
def osc_commonness(apps, schema_editor):
no_history()
Lexeme = apps.get_model('dictionary', 'Lexeme')
Classification = apps.get_model('dictionary', 'Classification')
LexemeCV = apps.get_model('dictionary', 'LexemeCV')
try:
commonness = Classification.objects.get(name='pospolitość')
commonness.parts_of_speech.add('osc')
common_name = commonness.values.get(label__contains='pospolita')
for osc in Lexeme.objects.filter(part_of_speech='osc'):
LexemeCV.objects.get_or_create(lexeme=osc, classification_value=common_name)
except ObjectDoesNotExist:
pass
except MultipleObjectsReturned:
pass
class Migration(migrations.Migration):
dependencies = [
('dictionary', '0002_auto_20151125_1201'),
]
operations = [
migrations.RunPython(osc_commonness),
]