Commit 943ee999 authored by Michal Čihař's avatar Michal Čihař

Reduce exception nesting

parent 2a377322
......@@ -161,9 +161,10 @@ def handle_translate(obj, request, user_locked, this_unit_url, next_unit_url):
form = TranslationForm(request.POST)
if not form.is_valid():
return
# Check whether translation is not outdated
obj.check_sync()
try:
try:
unit = Unit.objects.get(
checksum=form.cleaned_data['checksum'],
......@@ -176,6 +177,17 @@ def handle_translate(obj, request, user_locked, this_unit_url, next_unit_url):
checksum=form.cleaned_data['checksum'],
translation=obj
)[0]
except Unit.DoesNotExist:
weblate.logger.error(
'message %s disappeared!',
form.cleaned_data['checksum']
)
messages.error(
request,
_('Message you wanted to translate is no longer available!')
)
return
if 'suggest' in request.POST:
# Handle suggesion saving
user = request.user
......@@ -239,15 +251,6 @@ def handle_translate(obj, request, user_locked, this_unit_url, next_unit_url):
# Redirect to next entry
return HttpResponseRedirect(next_unit_url)
except Unit.DoesNotExist:
weblate.logger.error(
'message %s disappeared!',
form.cleaned_data['checksum']
)
messages.error(
request,
_('Message you wanted to translate is no longer available!')
)
def handle_merge(obj, request, next_unit_url):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment