Propagate some status variables

This commit is contained in:
Michal Čihař 2012-02-28 15:09:03 +01:00
parent f234a3bd06
commit 8eb8f991da
2 changed files with 15 additions and 0 deletions

View File

@ -5,6 +5,8 @@
{% include "translation_info.html" %}
<h2>{% trans "Translate" %}</h2>
{% endblock %}

View File

@ -37,9 +37,22 @@ def translate(request, project, subproject, lang):
except:
offset = 0
units = obj.unit_set.filter_type(rqtype)
total = units.count()
if offset >= total:
offset = total - 1
nextoffset = offset + 1
if nextoffset >= total:
nextoffset = None
prevoffset = offset - 1
if prevoffset < 0:
prevoffset = None
return render_to_response('translate.html', RequestContext(request, {
'object': obj,
'title': '%s @ Weblate' % (obj.__unicode__()),
'unit': units[offset],
'total': total,
'offset': offset,
'prevoffset': prevoffset,
'nextoffset': nextoffset,
}))