1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

È un'opera d'arte. Funziona tutto.

This commit is contained in:
Steffo 2019-01-09 17:19:39 +01:00
parent 5c7401af47
commit 1b2abfefdf
4 changed files with 25 additions and 5 deletions

12
db.py
View file

@ -701,6 +701,18 @@ class Discord(Base, Mini):
return "https://discordapp.com/assets/6debd47ed13483642cf09e832ed0bc1b.png" return "https://discordapp.com/assets/6debd47ed13483642cf09e832ed0bc1b.png"
return f"https://cdn.discordapp.com/avatars/{self.discord_id}/{self.avatar_hex}.png?size={size}" return f"https://cdn.discordapp.com/avatars/{self.discord_id}/{self.avatar_hex}.png?size={size}"
@classmethod
def mini_get_all(cls, session: Session):
return [dict(row) for row in session.execute(query_discord_music.all_query)]
@classmethod
def mini_get_single(cls, session: Session, **kwargs):
return session.execute(query_discord_music.one_query, {"royal": kwargs["royal"].id}).fetchone()
@classmethod
def mini_get_single_from_royal(cls, session: Session, royal: "Royal"):
return cls.mini_get_single(session, royal=royal)
class Overwatch(Base, Mini): class Overwatch(Base, Mini):
__tablename__ = "overwatch" __tablename__ = "overwatch"

View file

@ -16,7 +16,7 @@
<div class="game"> <div class="game">
<div class="game-panels"> <div class="game-panels">
{% for record in mini_data %} {% for record in mini_data %}
{% include "minis/" + record._mini_name + ".html" %} {% include "minis/" + mini_type._mini_name + ".html" %}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View file

@ -35,8 +35,10 @@
</div> </div>
{% endif %} {% endif %}
<div class="game-panels"> <div class="game-panels">
{% for record in mini_data %} {% for mini in mini_data %}
{% include "minis/" + record._mini_name + ".html" %} {% with record = mini["data"] %}
{% include "minis/" + mini["name"] + ".html" %}
{% endwith %}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View file

@ -118,9 +118,15 @@ def page_profile(name: str):
data = game.mini_get_single_from_royal(fl_g.session, user) data = game.mini_get_single_from_royal(fl_g.session, user)
# TODO: investigate on why instrumentedlists are returned # TODO: investigate on why instrumentedlists are returned
if isinstance(data, InstrumentedList): if isinstance(data, InstrumentedList):
mini_data.append(data[0]) mini_data.append({
"name": game._mini_name,
"data": data[0]
})
continue continue
mini_data.append(data) mini_data.append({
"name": game._mini_name,
"data": data
})
if css is not None: if css is not None:
converted_bio = Markup(markdown2.markdown(css.bio.replace("<", "&lt;"), converted_bio = Markup(markdown2.markdown(css.bio.replace("<", "&lt;"),
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])) extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"]))