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

Use new unit flags while browsing and counting units

parent af8b31fa
......@@ -592,13 +592,17 @@ class Translation(models.Model, URLMixin):
Updates translation statistics.
'''
self.total = self.unit_set.count()
self.fuzzy = self.unit_set.filter(fuzzy=True).count()
self.translated = self.unit_set.filter(translated=True).count()
self.failing_checks = self.unit_set.filter_checks(
'allchecks', self
self.fuzzy = self.unit_set.filter(
fuzzy=True
).count()
self.have_suggestion = self.unit_set.filter_type(
'suggestions', self
self.translated = self.unit_set.filter(
translated=True
).count()
self.failing_checks = self.unit_set.filter(
has_failing_check=True
).count()
self.have_suggestion = self.unit_set.filter(
has_suggestion=True
).count()
self.save()
self.store_hash()
......
......@@ -93,7 +93,7 @@ class UnitManager(models.Manager):
# Filter by language
if rqtype == 'allchecks':
checks = checks.filter(language=translation.language)
return self.filter(has_failing_check=True)
elif rqtype == 'sourcechecks':
checks = checks.filter(language=None)
filter_translated = False
......@@ -129,12 +129,7 @@ class UnitManager(models.Manager):
elif rqtype == 'untranslated':
return self.filter(translated=False)
elif rqtype == 'suggestions':
sugs = Suggestion.objects.filter(
language=translation.language,
project=translation.subproject.project
)
sugs = sugs.values_list('checksum', flat=True)
return self.filter(checksum__in=sugs)
return self.filter(has_suggestion=True)
elif rqtype == 'sourcecomments':
coms = Comment.objects.filter(
language=None,
......@@ -143,12 +138,9 @@ class UnitManager(models.Manager):
coms = coms.values_list('checksum', flat=True)
return self.filter(checksum__in=coms)
elif rqtype == 'targetcomments':
coms = Comment.objects.filter(
language=translation.language,
project=translation.subproject.project
)
coms = coms.values_list('checksum', flat=True)
return self.filter(checksum__in=coms)
return self.filter(has_comment=True)
elif rqtype == 'allchecks':
return self.filter(has_failing_check=True)
elif rqtype in CHECKS or rqtype in ['allchecks', 'sourcechecks']:
return self.filter_checks(rqtype, translation)
else:
......
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