diff --git a/files/assets/js/comments+submission_listing.js b/files/assets/js/comments+submission_listing.js index 55ce7c6ce..e70fc4a57 100644 --- a/files/assets/js/comments+submission_listing.js +++ b/files/assets/js/comments+submission_listing.js @@ -110,17 +110,22 @@ function poll_vote_1(oid, parentid, kind) { curr.value = full_oid } -function bet_vote(oid) { - for(let el of document.getElementsByClassName('bet')) { - el.disabled = true; - } - for(let el of document.getElementsByClassName('cost')) { - el.classList.add('d-none') - } - var scoretext = document.getElementById('option-' + oid); - var score = Number(scoretext.textContent); - scoretext.textContent = score + 1; - post(`/vote/post/option/${oid}`); - - document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200; +function bet_vote(t, oid) { + postToast(t, `/vote/post/option/${oid}`, + { + }, + () => { + for(let el of document.getElementsByClassName('bet')) { + el.disabled = true; + } + for(let el of document.getElementsByClassName('cost')) { + el.classList.add('d-none') + } + var scoretext = document.getElementById('option-' + oid); + var score = Number(scoretext.textContent); + scoretext.textContent = score + 1; + + document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - 200; + } + ); } diff --git a/files/classes/submission.py b/files/classes/submission.py index 6f895f7d5..655ef47ee 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -288,7 +288,7 @@ class Submission(Base): for o in self.options: if o.exclusive > 1: - body += f'''
= POLL_BET_COINS) or self.total_bet_voted(v): body += " disabled " diff --git a/files/routes/polls.py b/files/routes/polls.py index 5dbf56a54..8025c31cb 100644 --- a/files/routes/polls.py +++ b/files/routes/polls.py @@ -49,7 +49,7 @@ def vote_option(option_id, v): elif existing and not option.exclusive: g.db.delete(existing) - return "", 204 + return {"message": "Bet successful!"}, 204 @app.get("/votes/post/option/") @auth_required