Spieler können jetzt selbst eingetragene Spieler selber löschen solange der Gegner es noch nicht bestätigt hat.
This commit is contained in:
parent
3936a0b53b
commit
ad2089ec1f
|
|
@ -536,3 +536,27 @@ def set_match_counted(match_id):
|
|||
connection.commit()
|
||||
connection.close()
|
||||
|
||||
|
||||
|
||||
def get_submitted_matches(player_id):
|
||||
"""Holt alle offenen Matches, die der Spieler selbst eingetragen hat, aber vom Gegner noch nicht bestätigt wurden."""
|
||||
connection = sqlite3.connect(DB_PATH)
|
||||
connection.row_factory = sqlite3.Row
|
||||
cursor = connection.cursor()
|
||||
|
||||
# ACHTUNG: Wir joinen hier p2 (player2), weil wir den Namen des Gegners anzeigen wollen!
|
||||
query = """
|
||||
SELECT m.id AS match_id, m.score_player1, m.score_player2, m.played_at,
|
||||
sys.name AS system_name,
|
||||
p2.display_name AS p2_name
|
||||
FROM matches m
|
||||
JOIN gamesystems sys ON m.gamesystem_id = sys.id
|
||||
JOIN players p2 ON m.player2_id = p2.id
|
||||
WHERE m.player1_id = ? AND m.player2_check = 0
|
||||
"""
|
||||
|
||||
cursor.execute(query, (player_id,))
|
||||
rows = cursor.fetchall()
|
||||
connection.close()
|
||||
|
||||
return [dict(row) for row in rows]
|
||||
|
|
|
|||
|
|
@ -131,6 +131,33 @@ def setup_routes(admin_discord_id):
|
|||
# BESTÄTIGEN und spiel berechnen lassen
|
||||
ui.button("Bestätigen", color="positive", icon="check", on_click=lambda e, m_id=match['match_id']: acccept_match(m_id))
|
||||
|
||||
# ---------------------------
|
||||
# --- Selbst eingetragene, offene Spiele ---
|
||||
# ---------------------------
|
||||
submitted_matches = data_api.get_submitted_matches(player_id)
|
||||
|
||||
if len(submitted_matches) > 0:
|
||||
# Eine etwas dezentere Karte (grau)
|
||||
with ui.card().classes('w-full bg-zinc-800 border border-gray-600 mb-6'):
|
||||
ui.label(f"Warten auf Gegner: Du hast {len(submitted_matches)} offene(s) Spiel(e) eingetragen.").classes('text-xl font-bold text-gray-300 mb-2')
|
||||
|
||||
for match in submitted_matches:
|
||||
|
||||
# Die Lösch-Funktion, die beim Klick ausgeführt wird
|
||||
def retract_match(m_id):
|
||||
data_api.delete_match(m_id)
|
||||
ui.notify("Eingetragenes Spiel zurückgezogen!", color="warning")
|
||||
ui.navigate.reload()
|
||||
|
||||
# Für jedes Match machen wir eine kleine Reihe
|
||||
with ui.row().classes('w-full items-center justify-between bg-zinc-900 p-3 rounded shadow-inner'):
|
||||
|
||||
# Info-Text: Auf wen warten wir?
|
||||
info_text = f"[{match['system_name']}] Warten auf Bestätigung von {match['p2_name']} ({match['score_player1']} : {match['score_player2']})"
|
||||
ui.label(info_text).classes('text-lg text-gray-400')
|
||||
|
||||
# Der Zurückziehen-Button (wieder mit unserem lambda m_id=... Trick!)
|
||||
ui.button("Zurückziehen", color="warning", icon="delete", on_click=lambda e, m_id=match['match_id']: retract_match(m_id))
|
||||
|
||||
|
||||
# ---------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user