add_do_usuniecia_status.py 1.66 KB
#-*- coding:utf-8 -*-

from django.core.management.base import BaseCommand

from accounts.models import GroupSettings
from dictionary.models import LemmaStatusType, Lemma_Status, StageOfWork

class Command(BaseCommand):
    args = 'none'
    help = u'Add "do usunięcia" status to tool.' 

    def handle(self, **options):
        add_new_status()

def add_new_status():
    lex_stage_of_work = StageOfWork.objects.get(sym_name=u'lexicography')
    w_obrobce_status = Lemma_Status.objects.get(status=u'w obróbce')
    
    ### creating erase status type ###
    erase_type, xx = LemmaStatusType.objects.get_or_create(name='erase',
                                                           sym_name='erase',
                                                           priority=25)
    
    ### creating do usuniecia status
    do_usuniecia_status, xx = Lemma_Status.objects.get_or_create(status=u'do usunięcia',
                                                                 abort_status=w_obrobce_status,
                                                                 type=erase_type,
                                                                 stage_of_work=lex_stage_of_work,
                                                                 priority=25)
    w_obrobce_status.next_statuses.add(do_usuniecia_status)
    
    ### lexicographers
    lexicographers_setting = GroupSettings.objects.get(group__name=u'Leksykograf')
    lexicographers_setting.next_statuses.add(do_usuniecia_status)
    
    ### superlexicographers
    superlexicographers_setting = GroupSettings.objects.get(group__name=u'Superleksykograf')
    superlexicographers_setting.next_statuses.add(do_usuniecia_status)