feat/support show poll
This commit is contained in:
parent
b3e36c7b07
commit
b496c95f10
1 changed files with 13 additions and 1 deletions
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import pytz
|
||||
import json
|
||||
|
||||
from flask import render_template, request, url_for, redirect, flash, abort
|
||||
from flask_sqlalchemy import Pagination
|
||||
from BDSM import app, db
|
||||
from BDSM.models import Media, Settings, Toot, Emoji, Other
|
||||
from BDSM.models import Media, Poll, Settings, Toot, Emoji, Other
|
||||
from BDSM.toot import app_register, archive_toot, get_context
|
||||
from mastodon import Mastodon
|
||||
from types import SimpleNamespace
|
||||
|
@ -235,5 +236,16 @@ def process_toot(toots_):
|
|||
'''
|
||||
toot.content = toot.content.replace(emoji_shortcode, emoji_html)
|
||||
|
||||
if toot.poll_id != None:
|
||||
poll = Poll.query.get(toot.poll_id)
|
||||
poll_options = json.loads(poll.options.replace("\'", "\""))
|
||||
poll_count = str(poll.votes_count)
|
||||
poll_content = '<strong>总票数: ' + poll_count + '</strong><br>'
|
||||
|
||||
for i in poll_options:
|
||||
poll_content += i['title'] + " / " + str(i['votes_count']) + '<br>'
|
||||
|
||||
toot.content += poll_content
|
||||
|
||||
toots.append(toot)
|
||||
return toots
|
||||
|
|
Loading…
Reference in a new issue