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

Better check for existence

parent a0d156b2
......@@ -173,7 +173,7 @@ class Language(models.Model):
Checks whether there is a translation existing for this language.
'''
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):
'''
......
......@@ -23,9 +23,9 @@ class Command(BaseCommand):
for sug in Suggestion.objects.filter(language = lang, project = prj).iterator():
# 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)
if units.count() > 0:
if units.exists():
sug.delete()
# Remove duplicate suggestions
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()
......@@ -318,7 +318,7 @@ def auto_translation(request, project, subproject, lang):
for unit in units.iterator():
update = sources.filter(checksum = unit.checksum)
if update.count() > 0:
if update.exists():
# Get first entry
update = update[0]
# 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