summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-07-11 02:42:34 +0000
committerubq323 <ubq323>2021-07-11 02:42:34 +0000
commit94e93dffbc2f23823cfb6949828861063a3f3e23 (patch)
treebf6d2dce4753cb60afefe40d7be25775b2bb4ff2
parent3aa8279af5247ce34cfab8842afeb404f3864845 (diff)
fix indexing issue with displaying of votes
-rw-r--r--apioforum/thread.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/apioforum/thread.py b/apioforum/thread.py
index ec98d89..20b02ca 100644
--- a/apioforum/thread.py
+++ b/apioforum/thread.py
@@ -39,7 +39,8 @@ def view_thread(thread_id):
FROM poll_options
LEFT OUTER JOIN vote_counts ON poll_options.poll = vote_counts.poll
AND poll_options.option_idx = vote_counts.option_idx
- WHERE poll_options.poll = ?;
+ WHERE poll_options.poll = ?
+ ORDER BY option_idx asc;
""",(poll_row['id'],)).fetchall()
poll = {}
poll.update(poll_row)
@@ -126,7 +127,7 @@ def create_poll(thread_id):
cur.execute("UPDATE threads SET poll = ? WHERE threads.id = ?",(pollid,thread_id))
cur.executemany(
"INSERT INTO poll_options (poll,option_idx,text) VALUES (?,?,?)",
- zip(itertools.repeat(pollid),range(len(polloptions)),polloptions)
+ zip(itertools.repeat(pollid),range(1,len(polloptions)+1),polloptions)
)
db.commit()
flash("poll created successfully")