Show strings with suggestions

This commit is contained in:
Michal Čihař 2012-03-01 14:03:23 +01:00
parent 69b02bda49
commit 7b16bb1305
2 changed files with 12 additions and 0 deletions

View File

@ -42,9 +42,18 @@ class UnitManager(models.Manager):
return dbunit
def filter_type(self, rqtype):
import trans.models
if rqtype == 'all':
return self.all()
elif rqtype == 'fuzzy':
return self.filter(fuzzy = True)
elif rqtype == 'untranslated':
return self.filter(translated = False)
elif rqtype == 'suggestions':
sample = self.all()[0]
sugs = trans.models.Suggestion.objects.filter(
language = sample.translation.language,
project = sample.translation.subproject.project)
sugs = sugs.values_list('checksum', flat = True)
return self.filter(checksum__in = sugs)

View File

@ -318,10 +318,13 @@ class Translation(models.Model):
result = []
nottranslated = self.unit_set.filter_type('untranslated').count()
fuzzy = self.unit_set.filter_type('fuzzy').count()
suggestions = self.unit_set.filter_type('suggestions').count()
if nottranslated > 0:
result.append(('untranslated', _('Not translated strings (%d)') % nottranslated))
if fuzzy > 0:
result.append(('fuzzy', _('Fuzzy strings (%d)') % fuzzy))
if suggestions > 0:
result.append(('suggestions', _('Strings with suggestions (%d)') % suggestions))
return result