Compare commits
1 Commits
9093b1c77f
...
4bdadb5dee
Author | SHA1 | Date | |
---|---|---|---|
4bdadb5dee |
24
anonkun.py
24
anonkun.py
|
@ -107,30 +107,6 @@ def num_votes(option_id):
|
||||||
return db.get_num_votes(option_id)
|
return db.get_num_votes(option_id)
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter("split_options")
|
|
||||||
def split_options(options):
|
|
||||||
"""
|
|
||||||
Splits a polls options into a list.
|
|
||||||
"""
|
|
||||||
return options.split("\n")
|
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter("get_rolls")
|
|
||||||
def get_rolls(post_id):
|
|
||||||
"""
|
|
||||||
Gets the dice rolls for the template.
|
|
||||||
"""
|
|
||||||
return db.get_dice_rolls(post_id=post_id)
|
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter("get_options")
|
|
||||||
def get_options(post_id):
|
|
||||||
"""
|
|
||||||
Gets the poll options for the template.
|
|
||||||
"""
|
|
||||||
return db.get_poll_options(post_id=post_id)
|
|
||||||
|
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def minify(res):
|
def minify(res):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -288,13 +288,6 @@ def get_polls(quest_id):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def get_poll(post_id):
|
|
||||||
"""Gets poll information."""
|
|
||||||
data = _DB.execute(
|
|
||||||
"SELECT * FROM `polls` WHERE `post_id` = %s", (post_id,)).fetchall()
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def insert_poll_option(post_id, option_text):
|
def insert_poll_option(post_id, option_text):
|
||||||
"""Insert a new poll option. ips_voted will be NULL to start."""
|
"""Insert a new poll option. ips_voted will be NULL to start."""
|
||||||
_DB.execute(
|
_DB.execute(
|
||||||
|
|
|
@ -240,12 +240,10 @@
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
{% elif quest_post[2] == "dice" %}
|
{% elif quest_post[2] == "dice" %}
|
||||||
<h3>{{ quest_post[3] }} - {% if quest_post[0] == open_post_id %}Open{% else %}Closed{% endif %}</h3>
|
<h3>{{ quest_post[3] }} - {% if quest_post[0] == open_post_id %}Open{% else %}Closed{% endif %}</h3>
|
||||||
{% for dice_roll in quest_post[0]|get_rolls %}
|
{% for dice_roll in dice_rolls[quest_post[0]] %}
|
||||||
{% if dice_roll[2] == quest_post[0] %}
|
|
||||||
<div id="questRollId-{{ dice_roll[0] }}">
|
<div id="questRollId-{{ dice_roll[0] }}">
|
||||||
<b>Rolled {{ dice_roll[4] }} = {{ dice_roll[5] }} ({{ dice_roll[3] }}){% if quest_post[0]|dice_chal != 0 %} - {% if dice_roll[5] >= quest_post[0]|dice_chal %}Pass{% else %} Fail{% endif %}{% endif %}</b>
|
<b>Rolled {{ dice_roll[4] }} = {{ dice_roll[5] }} ({{ dice_roll[3] }}){% if quest_post[0]|dice_chal != 0 %} - {% if dice_roll[5] >= quest_post[0]|dice_chal %}Pass{% else %} Fail{% endif %}{% endif %}</b>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% elif quest_post[2] == "poll" %}
|
{% elif quest_post[2] == "poll" %}
|
||||||
<h3>{{ quest_post[3] }} - {% if quest_post[0] == open_post_id %}Open{% else %}Closed{% endif %}</h3>
|
<h3>{{ quest_post[3] }} - {% if quest_post[0] == open_post_id %}Open{% else %}Closed{% endif %}</h3>
|
||||||
|
@ -253,17 +251,15 @@
|
||||||
<col{% if quest_post[0] != open_post_id %} style="visibility: collapse;"{% endif %}/>
|
<col{% if quest_post[0] != open_post_id %} style="visibility: collapse;"{% endif %}/>
|
||||||
<col/>
|
<col/>
|
||||||
<col/>
|
<col/>
|
||||||
{% for option in options %}
|
{% for option in options[quest_post[0]] %}
|
||||||
{% if option[1] == quest_post[0] %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="pollCheckBox">
|
<td class="pollCheckBox">
|
||||||
<input type="checkbox" id="pollInput-{{ option[0] }}" onchange="pollVote({{ option[0] }})"/>
|
<input type="checkbox" id="pollInput-{{ option[0] }}" onchange="pollVote({{ option[0] }})"/>
|
||||||
<label for="pollInput-{{ option[0] }}"></label>
|
<label for="pollInput-{{ option[0] }}"></label>
|
||||||
</td>
|
</td>
|
||||||
<td class="option_text">{{ option[2] }}</td>
|
<td class="option_text">{{ option[2] }}</td>
|
||||||
<td class="optionVotes">0</td>
|
<td class="optionVotes">{{ option[0]|num_votes }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
17
views.py
17
views.py
|
@ -47,7 +47,6 @@ def quest(quest_title):
|
||||||
"""
|
"""
|
||||||
An arbituary quest page.
|
An arbituary quest page.
|
||||||
"""
|
"""
|
||||||
then = time.time()
|
|
||||||
ident_title, _, extra = quest_title.partition("/")
|
ident_title, _, extra = quest_title.partition("/")
|
||||||
data = db.get_quest_meta(ident_title=ident_title)
|
data = db.get_quest_meta(ident_title=ident_title)
|
||||||
if not data:
|
if not data:
|
||||||
|
@ -59,13 +58,19 @@ def quest(quest_title):
|
||||||
open_post_id = data[4]
|
open_post_id = data[4]
|
||||||
|
|
||||||
quest_posts = db.get_quest_data(quest_id)
|
quest_posts = db.get_quest_data(quest_id)
|
||||||
dice_rolls = db.get_dice_rolls(quest_id)
|
dice_rolls_raw = db.get_dice_rolls(quest_id)
|
||||||
options = db.get_poll_options(quest_id=quest_id)
|
dice_rolls = {roll[2]: [] for roll in dice_rolls_raw}
|
||||||
|
_ = [dice_rolls[roll[2]].append(roll) for roll in dice_rolls_raw]
|
||||||
|
del dice_rolls_raw
|
||||||
|
|
||||||
|
options_raw = db.get_poll_options(quest_id=quest_id)
|
||||||
|
options = {opt[1]: [] for opt in options_raw}
|
||||||
|
_ = [options[opt[1]].append(opt) for opt in options_raw]
|
||||||
|
del options_raw
|
||||||
|
|
||||||
messages = db.get_chat_messages(quest_id)
|
messages = db.get_chat_messages(quest_id)
|
||||||
|
|
||||||
temp = render_template('quest.html', **locals())
|
return render_template('quest.html', **locals())
|
||||||
print(time.time() - then)
|
|
||||||
return temp
|
|
||||||
|
|
||||||
|
|
||||||
@views.route("/quest/<path:quest_title>/edit_quest", methods=["GET", "POST"])
|
@views.route("/quest/<path:quest_title>/edit_quest", methods=["GET", "POST"])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user