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