From f208b5bdb254a49d469d350d24cb93b9f648afb2 Mon Sep 17 00:00:00 2001 From: Alexander Burdeiny Date: Sat, 2 Jul 2016 13:54:08 +0300 Subject: [PATCH] =?UTF-8?q?1384:=20=D0=AD=D1=82=D0=B0=D0=BF=20=E2=84=964?= =?UTF-8?q?=20-=20=D0=98=D0=BC=D1=8F=20URLa=20=D0=B2=D1=8B=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D0=B0=D0=BC=D0=B8,?= =?UTF-8?q?=20=D0=BE=D1=82=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0=20=D0=B2=20=D0=B0?= =?UTF-8?q?=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D0=B5=20=D1=81=D0=BE=D0=B1=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/check_translation.py | 27 +++++++++++++++++++ exposition/management/commands/check_url.py | 1 + fabfile.py | 1 + functions/admin_forms.py | 4 +++ 4 files changed, 33 insertions(+) create mode 100644 exposition/management/commands/check_translation.py diff --git a/exposition/management/commands/check_translation.py b/exposition/management/commands/check_translation.py new file mode 100644 index 00000000..c4d2adbf --- /dev/null +++ b/exposition/management/commands/check_translation.py @@ -0,0 +1,27 @@ +# -*- 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() diff --git a/exposition/management/commands/check_url.py b/exposition/management/commands/check_url.py index ec93f3cd..debc2901 100644 --- a/exposition/management/commands/check_url.py +++ b/exposition/management/commands/check_url.py @@ -13,6 +13,7 @@ class Command(NoArgsCommand): for model in [Conference, Exposition]: print('checking {name}'.format(name=model.__name__)) self.run_objects(model) + print('Done.') def run_objects(self, model): object_ids = [] diff --git a/fabfile.py b/fabfile.py index 70e4e4f0..f37141c0 100644 --- a/fabfile.py +++ b/fabfile.py @@ -180,3 +180,4 @@ def ticket1384(): run('python manage.py migrate exposition') run('python manage.py migrate conference') run('python manage.py check_url') + run('python manage.py check_translation') diff --git a/functions/admin_forms.py b/functions/admin_forms.py index 50aff523..6bbfa1ee 100644 --- a/functions/admin_forms.py +++ b/functions/admin_forms.py @@ -52,6 +52,7 @@ class AdminFilterForm(forms.Form): class EventsAdminFilterFormMixin(forms.Form): no_theme = forms.BooleanField(label=_(u'Без темы'), required=False) bad_url = forms.BooleanField(label=_(u'Подозрение на неправильный урл'), required=False) + url = forms.CharField(label=_(u'URL'), required=False) def filter(self): qs = super(EventsAdminFilterFormMixin, self).filter() @@ -59,4 +60,7 @@ class EventsAdminFilterFormMixin(forms.Form): qs = qs.filter(bad_url=True) if self.cleaned_data['no_theme']: qs = qs.filter(theme__isnull=True) + if self.cleaned_data['url']: + qs = qs.filter(url=self.cleaned_data['url']) + return qs