You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
971 B
27 lines
971 B
# -*- coding: utf-8 -*-
|
|
from django.core.management.base import NoArgsCommand
|
|
from django.conf import settings
|
|
|
|
from conference.models import Conference
|
|
from exposition.models import Exposition
|
|
from functions.form_check import translit_with_separator
|
|
|
|
|
|
class Command(NoArgsCommand):
|
|
objects_per_cycle = 1000
|
|
|
|
def handle_noargs(self, **options):
|
|
for model in [Conference, Exposition]:
|
|
for lang_code, name in settings.LANGUAGES:
|
|
print('checking {name}:{lang}'.format(name=model.__name__, lang=lang_code))
|
|
self.run_objects(model, lang_code)
|
|
print('Done.')
|
|
|
|
def run_objects(self, model, lang_code):
|
|
qs = model.objects.all().exclude(translations__language_code=lang_code)
|
|
print('Total objects {total}'.format(total=qs.count()))
|
|
for event in qs:
|
|
event.translate(lang_code)
|
|
if lang_code == 'ru':
|
|
event.bad_url = True
|
|
event.save()
|
|
|