feat/support show poll

This commit is contained in:
SouthFox 2022-11-15 18:08:03 +08:00
parent b3e36c7b07
commit b496c95f10

View file

@ -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