create_classifications.py
1.67 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
38
39
40
41
#-*- coding:utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from dictionary.models import Classification, ClassificationValue
class Command(BaseCommand):
args = 'none'
help = 'Creates default classifications'
def handle(self, **options):
create_classifications()
def get_permission(codename):
return Permission.objects.get(codename=codename)
def create_classifications():
Classification.objects.all().delete()
ClassificationValue.objects.all().delete()
commonness = Classification.objects.create(name=u'pospolitość')
common_name = ClassificationValue.objects.create(
label=u'pospolita', parent_node=None, classification=commonness)
proper_name = ClassificationValue.objects.create(
label=u'własna', parent_node=None, classification=commonness)
person = ClassificationValue.objects.create(
label=u'osoba', parent_node=proper_name, classification=commonness)
ClassificationValue.objects.create(
label=u'imię', parent_node=person, classification=commonness)
ClassificationValue.objects.create(
label=u'nazwisko', parent_node=person, classification=commonness)
ClassificationValue.objects.create(
label=u'patronimicum', parent_node=person, classification=commonness)
ClassificationValue.objects.create(
label=u'przydomek', parent_node=person, classification=commonness)
ClassificationValue.objects.create(
label=u'pseudonim', parent_node=person, classification=commonness)
ClassificationValue.objects.create(
label=u'geograficzna', parent_node=proper_name, classification=commonness)
ClassificationValue.objects.create(
label=u'organizacja', parent_node=proper_name, classification=commonness)