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

Better check for existence

parent a0d156b2
...@@ -173,7 +173,7 @@ class Language(models.Model): ...@@ -173,7 +173,7 @@ class Language(models.Model):
Checks whether there is a translation existing for this language. Checks whether there is a translation existing for this language.
''' '''
from weblate.trans.models import Translation from weblate.trans.models import Translation
return Translation.objects.filter(language = self).count() > 0 return Translation.objects.filter(language = self).exists()
def get_translated_percent(self): def get_translated_percent(self):
''' '''
......
...@@ -23,9 +23,9 @@ class Command(BaseCommand): ...@@ -23,9 +23,9 @@ class Command(BaseCommand):
for sug in Suggestion.objects.filter(language = lang, project = prj).iterator(): for sug in Suggestion.objects.filter(language = lang, project = prj).iterator():
# Remove suggestions with same text as real translation # Remove suggestions with same text as real translation
units = Unit.objects.filter(checksum = sug.checksum, translation__language = lang, translation__subproject__project = prj, target = sug.target) units = Unit.objects.filter(checksum = sug.checksum, translation__language = lang, translation__subproject__project = prj, target = sug.target)
if units.count() > 0: if units.exists():
sug.delete() sug.delete()
# Remove duplicate suggestions # Remove duplicate suggestions
sugs = Suggestion.objects.filter(checksum = sug.checksum, language = lang, project = prj, target = sug.target).exclude(id = sug.id) sugs = Suggestion.objects.filter(checksum = sug.checksum, language = lang, project = prj, target = sug.target).exclude(id = sug.id)
if sugs.count() > 0: if sugs.exists():
sugs.delete() sugs.delete()
...@@ -318,7 +318,7 @@ def auto_translation(request, project, subproject, lang): ...@@ -318,7 +318,7 @@ def auto_translation(request, project, subproject, lang):
for unit in units.iterator(): for unit in units.iterator():
update = sources.filter(checksum = unit.checksum) update = sources.filter(checksum = unit.checksum)
if update.count() > 0: if update.exists():
# Get first entry # Get first entry
update = update[0] update = update[0]
# No save if translation is same # No save if translation is same
......
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