Show - Form hack with vote buttons - CSRF protection
This commit is contained in:
parent
064406bf89
commit
c11a43b7c5
@ -181,6 +181,9 @@ a.episode .submission_cnt {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
.vote-btns form {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
.vote-positive {
|
.vote-positive {
|
||||||
background-color: #a4ffa7;
|
background-color: #a4ffa7;
|
||||||
color: #008005;
|
color: #008005;
|
||||||
|
@ -41,12 +41,18 @@
|
|||||||
<div class="submission{% if sbm.positives < sbm.negatives %} buried{% endif %}">
|
<div class="submission{% if sbm.positives < sbm.negatives %} buried{% endif %}">
|
||||||
<a href="{{sbm.url}}" class="link"><i class="fa fa-fw fa-globe"></i> {{sbm.url}}</a>
|
<a href="{{sbm.url}}" class="link"><i class="fa fa-fw fa-globe"></i> {{sbm.url}}</a>
|
||||||
<div class="vote-btns" data-vote-id="{{sbm.id}}">
|
<div class="vote-btns" data-vote-id="{{sbm.id}}">
|
||||||
<a href="/show/{{show.abbr}}/vote/{{sbm.id}}/1" class="vote-positive">
|
<form method="POST" action="/show/{{show.abbr}}/vote/{{sbm.id}}/1">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button class="vote-positive">
|
||||||
<i class="fa fa-fw fa-thumbs-up"></i> {{sbm.positives}}
|
<i class="fa fa-fw fa-thumbs-up"></i> {{sbm.positives}}
|
||||||
</a>
|
</button>
|
||||||
<a href="/show/{{show.abbr}}/vote/{{sbm.id}}/0" class="vote-negative">
|
</form>
|
||||||
|
<form method="POST" action="/show/{{show.abbr}}/vote/{{sbm.id}}/0">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button class="vote-negative">
|
||||||
<i class="fa fa-fw fa-thumbs-down"></i> {{sbm.negatives}}
|
<i class="fa fa-fw fa-thumbs-down"></i> {{sbm.negatives}}
|
||||||
</a>
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
|
@ -145,7 +145,7 @@ def SubmissionForm(req, abbreviation, season, episode):
|
|||||||
# Vote request
|
# Vote request
|
||||||
# /show/{{abbr}}/vote/{{submission id}}/{{positive == 1}}
|
# /show/{{abbr}}/vote/{{submission id}}/{{positive == 1}}
|
||||||
class SubmissionVoteSubmit(View):
|
class SubmissionVoteSubmit(View):
|
||||||
def get (self, req, abbreviation, subid, positive):
|
def post (self, req, abbreviation, subid, positive):
|
||||||
# Convert positive parameter into a boolean
|
# Convert positive parameter into a boolean
|
||||||
pos_bool = int(positive) == 1
|
pos_bool = int(positive) == 1
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user