cache_export.py
1.12 KB
# -*- coding: utf-8 -*-
from django.core.management.base import NoArgsCommand
from django.db import transaction
from dictionary.models import Vocabulary, CachedExport, Variant
from export.lexeme_export import LexemeExport
class Command(NoArgsCommand):
help = "Cache export into db."
def handle_noargs(self, **options):
transaction.enter_transaction_management()
vocabs = list(Vocabulary.objects.exclude(id='SGJP').values_list(
'id', flat=True))
CachedExport.objects.all().delete()
for variant in Variant.objects.filter(type=Variant.TYPE_EXPORT):
export_manager = LexemeExport(data={
'vocabs': vocabs,
'antivocabs': [],
'variant': variant.id,
'excluding_qualifiers': [],
'magic_qualifiers': [],
'refl': False,
'commonness': True,
'homonym_numbers': True,
'form_qualifiers': True,
}, cache=True, print_debug=True)
export_manager.export()
transaction.commit()
transaction.leave_transaction_management()