Skip to content

Commit

Permalink
Correct imports and structure of the try statements
Browse files Browse the repository at this point in the history
  • Loading branch information
wasswa-derick committed Aug 31, 2018
1 parent c39251d commit 7a4592e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions wger/manager/views/workout.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import json
from decimal import Decimal

from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse
from django.utils.datastructures import MultiValueDictKeyError
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.contrib import messages
from django.template.context_processors import csrf
Expand Down Expand Up @@ -64,8 +66,6 @@
WgerDeleteMixin
)
from wger.utils.helpers import make_token
from django.http import HttpResponse
from django.utils.datastructures import MultiValueDictKeyError


logger = logging.getLogger(__name__)
Expand All @@ -82,13 +82,11 @@ def overview(request):

if request.method == 'POST':
try:
request.FILES['workoutfile']
file = request.FILES['workoutfile']
except MultiValueDictKeyError:
messages.info(request, 'No File was Chosen for Importation!')
return HttpResponseRedirect('overview')

file = request.FILES['workoutfile']

try:
data_bytes = file.read()
data = data_bytes.decode("utf8")
Expand Down Expand Up @@ -161,6 +159,7 @@ def overview(request):
)

set_setting.save()

except (ValueError, KeyError, Exception) as e:
messages.info(request, 'The Workout JSON file is invalid.')
return HttpResponseRedirect('overview')
Expand Down

0 comments on commit 7a4592e

Please sign in to comment.