set_specialist.py 514 Bytes
from django.core.management.base import BaseCommand
from common.util import no_history
from dictionary.models import Qualifier, Lexeme


class Command(BaseCommand):
    help = "Set default 'specialist' value."

    def handle(self, *args, **options):
        set_specialist()


def set_specialist():
    no_history()
    scope_qualifiers = list(Qualifier.objects.filter(type=Qualifier.TYPE_SCOPE))
    scope_lexemes = Lexeme.objects.filter(qualifiers__in=scope_qualifiers)
    scope_lexemes.update(specialist=True)