From 5dd0fe15387357e5a84eaf1834e8c8d00e792ad3 Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:36:55 +0200 Subject: [PATCH] modified: app.py modified: templates/user_dashboard.html --- app.py | 24 ++----- templates/user_dashboard.html | 128 ++++++++++++++++++++++++++++++---- 2 files changed, 122 insertions(+), 30 deletions(-) diff --git a/app.py b/app.py index 4772e48..4bd1f53 100644 --- a/app.py +++ b/app.py @@ -228,30 +228,20 @@ def user_dashboard(): if "discord_user" in session: user_info = session["discord_user"] user_id = user_info["id"] - - # Verbindung zur Datenbank herstellen - connection = get_db_connection() # Stelle sicher, dass du die richtige Verbindung benutzt + connection = get_db_connection() cursor = connection.cursor(dictionary=True) - # Punkte und Rang aus der Datenbank abrufen - cursor.execute("SELECT points, rank FROM user_data WHERE user_id = %s", (user_id,)) + cursor.execute("SELECT points, permission, ban FROM user_data WHERE user_id = %s", (user_id,)) user_data = cursor.fetchone() cursor.close() connection.close() - - # Wenn der Benutzer existiert, werden die Daten an das Template übergeben - if user_data: - user_points = user_data["points"] - user_rank = user_data["rank"] - else: - # Falls keine Daten gefunden wurden, setze Standardwerte - user_points = 0 - user_rank = "User" - - return render_template("user_dashboard.html", user_info=user_info, user_points=user_points, user_rank=user_rank) - return redirect(url_for("login")) + if user_data: + return render_template("user_dashboard.html", user_info=user_info, user_data=user_data) + else: + return "User data not found", 404 + return redirect(url_for("landing_page")) @app.route("/logout") def logout(): diff --git a/templates/user_dashboard.html b/templates/user_dashboard.html index cd7fc3f..aabcf8c 100644 --- a/templates/user_dashboard.html +++ b/templates/user_dashboard.html @@ -1,50 +1,152 @@ + User Dashboard + + - {% include 'navigation.html' %} - -
-

Welcome, {{ user_info.username }}

-

Here you can view your points and other information.

+ + -
+ + + + +
+
+
+
+ Points +
-
Your Points
-

{{ user_points }} Points

+

{{ user_data.points }}

+

Points available

+
+
+ Rank +
-
Giveaways
-

Check out the giveaways you've won!

- View Giveaways + + {{ 'Owner' if user_data.permission == 10 else 'Admin' if user_data.permission == 8 else 'Mod' if user_data.permission == 5 else 'User' }} + +

Your current rank

+
+
+ Bot Status +
-
Your Rank
-

Rank: {{ user_rank }}

+ + {{ "Running" if bot_running else "Stopped" }} + +

Current Bot Status

+
+
+
+
+ +
+
+
+
Giveaways
+

Check out the giveaways you've won!

+ View Giveaways +
+
+
+ + +
+
+
+
+ Useful Links +
+
+ +
+
+

© 2024 Multus Bot | Built by SimolZimol | Exclusively on Ludi et Historia

+
+
+ +