From d2ef58f523e98a7019d9d36c5a9410ecbb10c6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 28 Feb 2012 15:00:23 +0100 Subject: [PATCH] Grab unit to translate --- trans/managers.py | 8 ++++++++ trans/models.py | 4 ++-- trans/views.py | 9 ++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/trans/managers.py b/trans/managers.py index 9bba61d19..f1dedff19 100644 --- a/trans/managers.py +++ b/trans/managers.py @@ -40,3 +40,11 @@ class UnitManager(models.Manager): dbunit.update_from_unit(unit, force) return dbunit + + def filter_type(self, rqtype): + if rqtype == 'all': + return self.all() + elif rqtype == 'fuzzy': + return self.filter(fuzzy = True) + elif rqtype == 'untranslated': + return self.filter(translated = False) diff --git a/trans/models.py b/trans/models.py index 64018d71a..368f0baa1 100644 --- a/trans/models.py +++ b/trans/models.py @@ -276,8 +276,8 @@ class Translation(models.Model): Returns list of failing checks on current translation. ''' result = [] - nottranslated = self.unit_set.filter(translated = False).count() - fuzzy = self.unit_set.filter(fuzzy = True).count() + nottranslated = self.unit_set.filter_type('untranslated').count() + fuzzy = self.unit_set.filter_type('fuzzy').count() if nottranslated > 0: result.append(('untranslated', _('Not translated strings (%d)') % nottranslated)) if fuzzy > 0: diff --git a/trans/views.py b/trans/views.py index abf44d721..e860f89bd 100644 --- a/trans/views.py +++ b/trans/views.py @@ -30,9 +30,16 @@ def show_translation(request, project, subproject, lang): def translate(request, project, subproject, lang): obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project) - + rqtype = request.REQUEST.get('type', 'all') + offset = request.REQUEST.get('offset', '0') + try: + offset = int(offset) + except: + offset = 0 + units = obj.unit_set.filter_type(rqtype) return render_to_response('translate.html', RequestContext(request, { 'object': obj, 'title': '%s @ Weblate' % (obj.__unicode__()), + 'unit': units[offset], }))