conserve lines, fix issue
This commit is contained in:
parent
c3eff9f88a
commit
1f71c26fe7
@ -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()
|
||||||
|
Reference in New Issue
Block a user