Grab unit to translate

This commit is contained in:
Michal Čihař 2012-02-28 15:00:23 +01:00
parent d293d97ecd
commit d2ef58f523
3 changed files with 18 additions and 3 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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],
}))