1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add flask page

This commit is contained in:
Steffo 2018-11-06 23:18:02 +01:00
parent ab31249100
commit 628b82fcfd
2 changed files with 5 additions and 10 deletions

View file

@ -25,7 +25,7 @@
{% if record["fav_song"] %}
<div class="game-title fav-video">Canzone preferita</div>
<div class="game-score fav-video" title="{{ record["fav_song"] }}">
{{ record["fav_song"] }}
<a href="/music/{{ record["discord_id"] }}">{{ record["fav_song"] }}</a>
</div>
<div class="game-extra fav-video">{{ record["max_plays"] }}x</div>
{% else %}

View file

@ -342,20 +342,15 @@ def page_music():
return render_template("topsongs.html", songs=songs)
@app.route("/music/<name>")
def page_music_individual(name: str):
@app.route("/music/<discord_id>")
def page_music_individual(discord_id: str):
db_session = db.Session()
user = db_session.query(db.Royal).filter_by(username=name).one_or_none()
if user is None:
db_session.close()
abort(404)
return
discord = db_session.query(db.Discord).filter_by(royal=user).one_or_none()
discord = db_session.query(db.Discord).filter_by(discord_id=discord_id).one_or_none()
if discord is None:
db_session.close()
abort(404)
return
songs = db_session.execute(query_discord_music.single_top_songs, {"discordid": discord.id})
songs = db_session.execute(query_discord_music.single_top_songs, {"discordid": discord.discord_id})
db_session.close()
return render_template("topsongs.html", songs=songs, discord=discord)