modified: app.py
modified: templates/user_dashboard.html
This commit is contained in:
17
app.py
17
app.py
@@ -241,12 +241,11 @@ def callback():
|
|||||||
|
|
||||||
@app.route("/user_dashboard/<int:guild_id>")
|
@app.route("/user_dashboard/<int:guild_id>")
|
||||||
def user_dashboard(guild_id):
|
def user_dashboard(guild_id):
|
||||||
"""Serverbasiertes User-Dashboard."""
|
"""Serverbasiertes User-Dashboard"""
|
||||||
if "discord_user" in session:
|
if g.user_info:
|
||||||
user_info = session["discord_user"]
|
user_id = g.user_info["id"]
|
||||||
user_id = user_info["id"]
|
|
||||||
|
|
||||||
# Verbinde mit der Datenbank, um serverbezogene Nutzerdaten zu laden
|
# Hole die serverbezogenen Nutzerdaten
|
||||||
connection = get_db_connection()
|
connection = get_db_connection()
|
||||||
cursor = connection.cursor(dictionary=True)
|
cursor = connection.cursor(dictionary=True)
|
||||||
|
|
||||||
@@ -256,16 +255,12 @@ def user_dashboard(guild_id):
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
# Überprüfe, ob serverbezogene Daten gefunden wurden
|
|
||||||
if user_data:
|
if user_data:
|
||||||
g.guild_id = guild_id # Setzt guild_id in g, falls es auf der Seite benötigt wird
|
g.user_data = user_data # Setze user_data in g für den Zugang in den Templates
|
||||||
g.user_data = user_data # Setzt user_data in g für die Seite
|
|
||||||
return render_template("user_dashboard.html")
|
return render_template("user_dashboard.html")
|
||||||
else:
|
else:
|
||||||
flash("No data found for this server.", "warning")
|
flash("You do not have access to this server's data.", "warning")
|
||||||
return redirect(url_for("user_landing_page"))
|
return redirect(url_for("user_landing_page"))
|
||||||
|
|
||||||
# Wenn der Benutzer nicht eingeloggt ist, zurück zur Landing Page
|
|
||||||
return redirect(url_for("landing_page"))
|
return redirect(url_for("landing_page"))
|
||||||
|
|
||||||
@app.route("/server_admin_dashboard/<int:guild_id>")
|
@app.route("/server_admin_dashboard/<int:guild_id>")
|
||||||
|
|||||||
@@ -12,9 +12,13 @@
|
|||||||
{% include 'navigation.html' %}
|
{% include 'navigation.html' %}
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
<h1>Welcome, {{ g.user_info['username'] }}!</h1>
|
<h1>Welcome, {{ g.user_info['username'] }}!</h1>
|
||||||
<p>Server ID: {{ g.guild_id }}</p>
|
{% if g.user_data %}
|
||||||
<p>Your Points: {{ g.user_data['points'] }}</p>
|
<p>Your Points: {{ g.user_data['points'] }}</p>
|
||||||
<p>Level: {{ g.user_data['level'] }}</p>
|
<p>Level: {{ g.user_data['level'] }}</p>
|
||||||
|
<p>Server ID: {{ g.guild_id }}</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-danger">No data available for this server.</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user