Commit e1cfbc0d authored by Michal Čihař's avatar Michal Čihař

Cleanup per language

parent 6b4970a1
from django.core.management.base import BaseCommand, CommandError
from trans.models import Suggestion, Check, Unit
from lang.models import Language
from optparse import make_option
class Command(BaseCommand):
help = 'clenups orphaned checks and suggestions'
def handle(self, *args, **options):
units = Unit.objects.values('checksum').distinct()
Check.objects.exclude(checksum__in = units).delete()
Suggestion.objects.exclude(checksum__in = units).delete()
for lang in Language.objects.all():
units = Unit.objects.filter(translation__language = lang).values('checksum').distinct()
Check.objects.filter(language = lang).exclude(checksum__in = units).delete()
Suggestion.objects.filter(language = lang).exclude(checksum__in = units).delete()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment