create_classifications.py 1.67 KB
#-*- 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)