Properly handle when message has disappeared
This commit is contained in:
parent
85c0ddb2dc
commit
6d88952df5
@ -52,20 +52,26 @@ def translate(request, project, subproject, lang):
|
|||||||
except:
|
except:
|
||||||
pos = -1
|
pos = -1
|
||||||
|
|
||||||
|
unit = None
|
||||||
|
|
||||||
# Any form submitted?
|
# Any form submitted?
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = TranslationForm(request.POST)
|
form = TranslationForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
obj.check_sync()
|
obj.check_sync()
|
||||||
unit = Unit.objects.get(checksum = form.cleaned_data['checksum'], translation = obj)
|
try:
|
||||||
unit.target = form.cleaned_data['target']
|
unit = Unit.objects.get(checksum = form.cleaned_data['checksum'], translation = obj)
|
||||||
unit.fuzzy = form.cleaned_data['fuzzy']
|
unit.target = form.cleaned_data['target']
|
||||||
unit.save_backend(request)
|
unit.fuzzy = form.cleaned_data['fuzzy']
|
||||||
|
unit.save_backend(request)
|
||||||
|
|
||||||
# Check and save
|
# Check and save
|
||||||
return HttpResponseRedirect('%s?type=%s&oldpos=%d' % (obj.get_translate_url(), rqtype, pos))
|
return HttpResponseRedirect('%s?type=%s&oldpos=%d' % (obj.get_translate_url(), rqtype, pos))
|
||||||
|
except Unit.DoesNotExist:
|
||||||
|
messages.add_message(request, messages.ERROR, _('Message you wanted to translate is no longer available!'))
|
||||||
|
|
||||||
else:
|
# If we failed to get unit above or on no POST
|
||||||
|
if unit is None:
|
||||||
# What unit to show
|
# What unit to show
|
||||||
if direction == 'back':
|
if direction == 'back':
|
||||||
units = obj.unit_set.filter_type(rqtype).filter(position__lt = pos)
|
units = obj.unit_set.filter_type(rqtype).filter(position__lt = pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user