From 7b16bb1305a99e8bc26a0f2d881e709b1f13376b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 1 Mar 2012 14:03:23 +0100 Subject: [PATCH] Show strings with suggestions --- trans/managers.py | 9 +++++++++ trans/models.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/trans/managers.py b/trans/managers.py index 859ecc856..eb9d3964e 100644 --- a/trans/managers.py +++ b/trans/managers.py @@ -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) + diff --git a/trans/models.py b/trans/models.py index 40d9f4560..7d25c3417 100644 --- a/trans/models.py +++ b/trans/models.py @@ -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