commit
36511d1a13
3 changed files with 15 additions and 15 deletions
|
@ -71,10 +71,6 @@ def vote_page(request, delta):
|
||||||
except PageVoteVoter.DoesNotExist:
|
except PageVoteVoter.DoesNotExist:
|
||||||
# We must continue racing in case this is exploited to manipulate votes.
|
# We must continue racing in case this is exploited to manipulate votes.
|
||||||
continue
|
continue
|
||||||
if -vote.score != delta:
|
|
||||||
return HttpResponseBadRequest(
|
|
||||||
_("You already voted."), content_type="text/plain"
|
|
||||||
)
|
|
||||||
vote.delete()
|
vote.delete()
|
||||||
PageVote.objects.filter(id=pagevote_id).update(
|
PageVote.objects.filter(id=pagevote_id).update(
|
||||||
score=F("score") - vote.score
|
score=F("score") - vote.score
|
||||||
|
|
|
@ -41,11 +41,13 @@
|
||||||
if ($votes.downvote.hasClass('voted')) {
|
if ($votes.downvote.hasClass('voted')) {
|
||||||
delta = 2;
|
delta = 2;
|
||||||
}
|
}
|
||||||
ajax_vote('{{ url('pagevote_upvote') }}', id, delta, function () {
|
for (let i = 0; i < delta; i++) {
|
||||||
if ($votes.downvote.hasClass('voted'))
|
ajax_vote('{{ url('pagevote_upvote') }}', id, 1, function () {
|
||||||
$votes.downvote.removeClass('voted');
|
if ($votes.downvote.hasClass('voted'))
|
||||||
$votes.upvote.addClass('voted');
|
$votes.downvote.removeClass('voted');
|
||||||
});
|
$votes.upvote.addClass('voted');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,11 +63,13 @@
|
||||||
if ($votes.upvote.hasClass('voted')) {
|
if ($votes.upvote.hasClass('voted')) {
|
||||||
delta = -2;
|
delta = -2;
|
||||||
}
|
}
|
||||||
ajax_vote('{{ url('pagevote_downvote') }}', id, delta, function () {
|
for (let i = 0; i > delta; i--) {
|
||||||
if ($votes.upvote.hasClass('voted'))
|
ajax_vote('{{ url('pagevote_downvote') }}', id, -1, function () {
|
||||||
$votes.upvote.removeClass('voted');
|
if ($votes.upvote.hasClass('voted'))
|
||||||
$votes.downvote.addClass('voted');
|
$votes.upvote.removeClass('voted');
|
||||||
});
|
$votes.downvote.addClass('voted');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</script>
|
</script>
|
||||||
{% include "contest/media-js.html" %}
|
{% include "contest/media-js.html" %}
|
||||||
{% include "comments/media-js.html" %}
|
{% include "comments/media-js.html" %}
|
||||||
{% include "actionbar/media-css.html" %}
|
{% include "actionbar/media-js.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content_media %}
|
{% block content_media %}
|
||||||
|
|
Loading…
Reference in a new issue