create_roles_display.py 3.77 KB
#! /usr/bin/python
# -*- coding: utf-8 -*-

from django.core.management.base import BaseCommand

from semantics.models import SemanticRole, SemanticRolesDisplay

#==========================================================#
class Command(BaseCommand):
    args = 'none'
    help = ''

    def handle(self, **options):
        import_roles_table()
        
def import_roles_table():
    # row 1:
    display = SemanticRolesDisplay(row=1, column=1, rowspan=1, colspan=1, caption="")
    display.save()
    display = SemanticRolesDisplay(row=1, column=2, rowspan=1, colspan=1, caption="Grupa inicjująca")
    display.save()
    display = SemanticRolesDisplay(row=1, column=3, rowspan=1, colspan=1, caption="Grupa towarzysząca")
    display.save()
    display = SemanticRolesDisplay(row=1, column=4, rowspan=1, colspan=1, caption="Grupa zamykająca")
    display.save()

    # row 2
    display = SemanticRolesDisplay(row=2, column=1, rowspan=1, colspan=1, caption="Podstawowe")
    display.save()
    display = SemanticRolesDisplay(row=2, column=2, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Initiator')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Stimulus')
    display.roles.add(role)
    display = SemanticRolesDisplay(row=2, column=3, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Theme')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Experiencer')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Factor')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Instrument')
    display.roles.add(role)
    display = SemanticRolesDisplay(row=2, column=4, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Recipient')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Result')
    display.roles.add(role)

    # row 3:
    display = SemanticRolesDisplay(row=3, column=1, rowspan=1, colspan=1, caption="Uzupełniające")
    display.save()
    display = SemanticRolesDisplay(row=3, column=2, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Cause')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Condition')
    display.roles.add(role)
    display = SemanticRolesDisplay(row=3, column=3, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Attribute')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Manner')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Measure')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Location')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Path')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Time')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Duration')
    display.roles.add(role)
    display = SemanticRolesDisplay(row=3, column=4, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Purpose')
    display.roles.add(role)

    # row 4:
    display = SemanticRolesDisplay(row=4, column=1, rowspan=1, colspan=1, caption="Atrybuty")
    display.save()
    display = SemanticRolesDisplay(row=4, column=2, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Source')
    display.roles.add(role)
    display = SemanticRolesDisplay(row=4, column=3, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Foreground')
    display.roles.add(role)
    role = SemanticRole.objects.get(role='Background')
    display.roles.add(role)
    display = SemanticRolesDisplay(row=4, column=4, rowspan=1, colspan=1)
    display.save()
    role = SemanticRole.objects.get(role='Goal')
    display.roles.add(role)