Link to go to previous translation

This commit is contained in:
Michal Čihař 2012-02-29 13:02:43 +01:00
parent 8fb99a9eee
commit 466c6a76f5
2 changed files with 7 additions and 2 deletions

View File

@ -29,8 +29,9 @@
<tr><th>{% trans "Flags" %}</th></tr>
<tr><td>{{ unit.flags }}</td></tr>
<tr><td></td><td>
<a href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;oldpos={{ unit.position }}&amp;dir=back">{% trans "Previous" %}</a>
<input type="submit" value="{% trans "Save" %}" />
<a href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;oldpos={{ unit.position }}">{% trans "Skip" %}</a>
<a href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;oldpos={{ unit.position }}">{% trans "Next" %}</a>
</table>
</form>

View File

@ -43,6 +43,7 @@ def translate(request, project, subproject, lang):
# Check where we are
rqtype = request.REQUEST.get('type', 'all')
direction = request.REQUEST.get('dir', 'forward')
pos = request.REQUEST.get('oldpos', '-1')
try:
pos = int(pos)
@ -63,7 +64,10 @@ def translate(request, project, subproject, lang):
else:
# What unit to show
unit = obj.unit_set.filter_type(rqtype).filter(position__gt = pos)[0]
if direction == 'back':
unit = obj.unit_set.filter_type(rqtype).filter(position__lt = pos)[0]
else:
unit = obj.unit_set.filter_type(rqtype).filter(position__gt = pos)[0]
# Prepare form
form = TranslationForm(initial = {