Adding duplicate vote detection

This commit is contained in:
Jonathan Ervine
2020-11-26 10:54:41 +08:00
parent d7ce602fb0
commit 015f576429
2 changed files with 23 additions and 3 deletions
+3 -3
View File
@@ -134,7 +134,6 @@ def hkfcDMotmAdmin():
if form.saveButton.data:
flash('Settings saved!')
urlSuffix = randomUrlSuffix(8)
print(urlSuffix)
sql3 = "UPDATE hkfcDAdminSettings SET motmUrlSuffix='" + urlSuffix + "' WHERE userid='admin'"
sql_write_static(sql3)
flash('MotM URL https://hockey.ervine.dev/hkfc-d/motm/'+urlSuffix)
@@ -146,7 +145,6 @@ def hkfcDMotmAdmin():
sql6 = "SELECT motmUrlSuffix FROM hkfcDAdminSettings WHERE userid='admin'"
tempSuffix = sql_read_static(sql6)
currSuffix = tempSuffix[0]['motmUrlSuffix']
print(currSuffix)
flash('Man of the Match vote is now activated')
flash('MotM URL https://hockey.ervine.dev/hkfc-d/motm/'+currSuffix)
else:
@@ -241,8 +239,10 @@ def hkfcD_vote_thanks():
if prev_identity:
vote_query = "SELECT dotd_" + _matchDate + " FROM motmSessions WHERE sessionID='" + prev_identity + "'"
vote_check = sql_read(vote_query)
if vote_check:
vote_valid = vote_check[0]['dotd_" + _matchDate + "']
if vote_valid:
warn("Naughty, naughty, you've already voted!")
return render_template('_hkfcDVoteFraud.html', sessionID=prev_identity)
else:
sql = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, motmTotal, motm_" + _matchDate + ") SELECT playerNumber, playerNickname, '1', '1' FROM _HKFC_players WHERE playerNumber='" + _motm + "' ON DUPLICATE KEY UPDATE motmTotal = motmTotal + 1, motm_" + _matchDate + " = motm_" + _matchDate + " + 1"
sql2 = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, dotdTotal, dotd_" + _matchDate + ") SELECT playerNumber, playerNickname, '1', '1' FROM _HKFC_players WHERE playerNumber='" + _dotd + "' ON DUPLICATE KEY UPDATE dotdTotal = dotdTotal + 1, dotd_" + _matchDate + " = dotd_" + _matchDate + " + 1"