conserve lines, fix issue

This commit is contained in:
Evert Prants 2017-11-11 12:41:41 +02:00
parent c3eff9f88a
commit 1f71c26fe7
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -88,10 +88,8 @@ class SubmissionVoteSubmit(View):
pos_bool = int(positive) == 1
# Check for login status
if not req.session['user_id']:
r = HttpResponse('<h1>Error</h1><p>You need to be logged in to vote. Please <a href=/login>log in</a></p>')
r.status = 400
return r
if not 'user_id' in req.session:
return HttpResponse('<h1>Error</h1><p>You need to be logged in to vote. Please <a href=/login>log in</a></p>', status=400)
user = User.objects.get(user_id=req.session['user_id'])
@ -104,9 +102,7 @@ class SubmissionVoteSubmit(View):
# Prevent voting for own submission
if submission.user == user:
r = HttpResponse('<h1>Error</h1><p>You cannot vote for your own submission.</p>')
r.status = 400
return r
return HttpResponse('<h1>Error</h1><p>You cannot vote for your own submission.</p>', status=400)
# Allow changing a vote from positive to negative or vice-versa. Delete vote if its a re-vote
vote = submission.votes.filter(user=user,submission__id=submission.id).first()