Commit 316b760a8fccfaa2ff5351647ce0340ea6982aa7

Authored by Tomasz Bartosiak
2 parents 390a4747 dcf4b657

Merge branch 'tomek'

semantics/management/commands/update_roles.py 0 → 100644
  1 +#! /usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +from django.core.management.base import BaseCommand
  5 +from settings import PROJECT_PATH
  6 +
  7 +from semantics.models import SemanticRole, Complement, SemanticRolesDisplay
  8 +
  9 +#==========================================================#
  10 +
  11 +class Command(BaseCommand):
  12 + args = 'none'
  13 + help = ''
  14 +
  15 + def handle(self, **options):
  16 + update_roles()
  17 +
  18 +def update_roles():
  19 +
  20 + cause_complements = Complement.objects.filter(roles__role="Cause")
  21 +
  22 + cause = SemanticRole.objects.get(role="Cause")
  23 + condition = SemanticRole.objects.get(role="Condition")
  24 + condition.color = cause.color
  25 + condition.save()
  26 +
  27 + for complement in cause_complements:
  28 + complement.roles.remove(cause)
  29 + complement.roles.add(condition)
  30 +
  31 + display = SemanticRolesDisplay.objects.get(roles__role="Cause")
  32 + display.roles.remove(cause)
  33 +
  34 + cause.delete()
  35 +
  36 +
  37 +
... ...