From db97fe0e7e75eb9f2c9e6d6cec4e9c31ecbfb5a5 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 23 May 2023 22:14:39 +0200 Subject: [PATCH] Now you can only ask for one song at a time (in the contest) --- karaoke.py | 18 ++++++++++++++++++ tpl/blocks/karaoke.html | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/karaoke.py b/karaoke.py index 7b8cf21..2553b32 100644 --- a/karaoke.py +++ b/karaoke.py @@ -14,6 +14,24 @@ import json bp = Blueprint("karaoke", url_prefix="/manage/karaoke") +@bp.get("/admin") +async def show_songs(request, order: Order): + + if order.code not in ['9YKGJ', 'CMPQG']: + raise exceptions.Forbidden("Birichino") + + orders = [x for x in request.app.ctx.om.cache.values() if x.karaoke_songs] + + songs = [] + for o in orders: + if not o.karaoke_songs: continue + + for song, data in o.karaoke_songs.items(): + songs.append({'song': song, 'order': o, **data}) + + tpl = request.app.ctx.tpl.get_template('karaoke_admin.html') + return html(tpl.render(songs=songs)) + @bp.post("/add") async def add_song(request, order: Order): if not order: raise exceptions.Forbidden("You have been logged out. Please access the link in your E-Mail to login again!") diff --git a/tpl/blocks/karaoke.html b/tpl/blocks/karaoke.html index 8cea36f..5d5fa38 100644 --- a/tpl/blocks/karaoke.html +++ b/tpl/blocks/karaoke.html @@ -3,6 +3,7 @@

Singing is the spirit of Karaoke! If you like doing it join us for some fun with your favourite songs!
You can still just come to the desk and ask for a song, but keep in mind we will always give priority to requests that came through the form. Also, special matters or difficult to find songs will only be honored by the form!

Participate in the contest!

You can either decide to just sing, or let others vote you (anonymously) and try to win the prize! If you wish to send a song for the contest, make sure to toggle the appropriate option.

+ {% set ns = namespace(contest=false) %} {% if order.karaoke_songs %}

Your requests

@@ -13,7 +14,7 @@ {% for song, data in order.karaoke_songs.items() %} - + @@ -24,7 +25,7 @@

Request a new song

- +
{% if data['contest'] %}🎵{% else %}🏆{% endif %} {{song}}{% if data['contest'] %}🏆{% set ns.contest = true %}{% else %}🎵{% endif %} {{song}} {% if data['approved'] %}Approved{% elif data['approved'] is none %}Pending{% else %}Rejected{% endif %} {% if data['approved'] is none %}Delete{% endif %}