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