modified: app.py
modified: templates/server_admin_dashboard.html modified: templates/user_dashboard.html
This commit is contained in:
22
app.py
22
app.py
@@ -290,19 +290,21 @@ def user_server_data(guild_id):
|
|||||||
|
|
||||||
@app.route("/server_admin_dashboard/<int:guild_id>")
|
@app.route("/server_admin_dashboard/<int:guild_id>")
|
||||||
def server_admin_dashboard(guild_id):
|
def server_admin_dashboard(guild_id):
|
||||||
"""Serverbasiertes Admin-Dashboard für server-spezifische Admin-Rechte"""
|
"""Serverbasiertes Admin-Dashboard für server-spezifische Admin-Rechte."""
|
||||||
user_info = session.get("discord_user")
|
user_info = session.get("discord_user")
|
||||||
if user_info:
|
if user_info:
|
||||||
user_id = user_info["id"]
|
user_id = user_info["id"]
|
||||||
|
|
||||||
# Überprüfe, ob der Benutzer Admin-Rechte auf dem spezifischen Server hat
|
# Überprüfen, ob der Benutzer Admin-Rechte auf dem Server hat
|
||||||
|
if is_server_admin(guild_id):
|
||||||
connection = get_db_connection()
|
connection = get_db_connection()
|
||||||
cursor = connection.cursor(dictionary=True)
|
cursor = connection.cursor(dictionary=True)
|
||||||
|
|
||||||
cursor.execute("SELECT permission FROM user_data WHERE user_id = %s AND guild_id = %s", (user_id, guild_id))
|
# Hole die Giveaways für den spezifischen Server
|
||||||
user_data = cursor.fetchone()
|
cursor.execute("SELECT * FROM giveaway_data WHERE guild_id = %s", (guild_id,))
|
||||||
|
giveaways = cursor.fetchall()
|
||||||
|
|
||||||
# Hole den Gildennamen aus der guilds-Tabelle, falls verfügbar
|
# Hole den Gildennamen aus der guilds-Tabelle
|
||||||
cursor.execute("SELECT name FROM guilds WHERE guild_id = %s", (guild_id,))
|
cursor.execute("SELECT name FROM guilds WHERE guild_id = %s", (guild_id,))
|
||||||
guild_name_result = cursor.fetchone()
|
guild_name_result = cursor.fetchone()
|
||||||
guild_name = guild_name_result["name"] if guild_name_result else "Unknown Guild"
|
guild_name = guild_name_result["name"] if guild_name_result else "Unknown Guild"
|
||||||
@@ -310,16 +312,14 @@ def server_admin_dashboard(guild_id):
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
# Prüfen, ob der Benutzer Adminrechte für die spezifische Gilde hat
|
g.guild_id = guild_id
|
||||||
if user_data and user_data['permission'] >= 8:
|
g.guild_name = guild_name
|
||||||
g.guild_id = guild_id # Setze `g.guild_id` für die Vorlage
|
return render_template("server_admin_dashboard.html", giveaways=giveaways, guild_id=guild_id, guild_name=guild_name)
|
||||||
g.guild_name = guild_name # Setze `g.guild_name` für die Anzeige
|
|
||||||
return render_template("server_admin_dashboard.html", guild_id=guild_id, guild_name=guild_name)
|
|
||||||
|
|
||||||
# Falls der Benutzer keine Admin-Rechte hat, zurück zur Landing-Page
|
|
||||||
flash("You do not have permission to access this server's admin dashboard.", "danger")
|
flash("You do not have permission to access this server's admin dashboard.", "danger")
|
||||||
return redirect(url_for("user_landing_page"))
|
return redirect(url_for("user_landing_page"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/ban_user/<int:guild_id>/<int:user_id>")
|
@app.route("/ban_user/<int:guild_id>/<int:user_id>")
|
||||||
def ban_user(guild_id, user_id):
|
def ban_user(guild_id, user_id):
|
||||||
"""Banned einen Benutzer auf einem spezifischen Server."""
|
"""Banned einen Benutzer auf einem spezifischen Server."""
|
||||||
|
|||||||
@@ -1,36 +1,54 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Server Admin Dashboard</title>
|
<title>Server Admin Dashboard</title>
|
||||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% include 'navigation.html' %}
|
{% include 'navigation.html' %}
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
<h1 class="text-center">Server Admin Dashboard for {{ g.guild_name }}</h1>
|
<h1 class="text-center">Server Admin Dashboard for {{ g.guild_name }}</h1>
|
||||||
<p class="text-center">Manage server-specific settings for server <strong>{{ g.guild_id }}</strong>.</p>
|
<p class="text-center">Manage server-specific settings for server <strong>{{ g.guild_id }}</strong>.</p>
|
||||||
|
|
||||||
<!-- Server Management Options -->
|
<!-- Giveaway Management -->
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Giveaway Management</h5>
|
<h5 class="card-title">Giveaway Management</h5>
|
||||||
<p class="card-text">Manage and view all active giveaways for this server.</p>
|
<p class="card-text">Manage and view all active giveaways for this server.</p>
|
||||||
<a href="{{ url_for('server_giveaways', guild_id=g.guild_id) }}" class="btn btn-info btn-block">View Giveaways</a>
|
<table class="table table-bordered mt-4">
|
||||||
</div>
|
<thead>
|
||||||
</div>
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
<div class="card mt-4">
|
<th>Platform</th>
|
||||||
<div class="card-body">
|
<th>Winner</th>
|
||||||
<h5 class="card-title">Manage Points</h5>
|
<th>Status</th>
|
||||||
<p class="card-text">Manage user points for this server.</p>
|
<th>Actions</th>
|
||||||
<a href="{{ url_for('update_points', guild_id=g.guild_id, user_id=g.user_info['id']) }}" class="btn btn-info btn-block">Manage Points</a>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for giveaway in giveaways %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ giveaway.name }}</td>
|
||||||
|
<td>{{ giveaway.platform }}</td>
|
||||||
|
<td>{{ giveaway.winner_dc_id }}</td>
|
||||||
|
<td>
|
||||||
|
{% if giveaway.aktiv %}
|
||||||
|
<span class="badge badge-success">Redeemed</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="badge badge-warning">Not Redeemed</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url_for('edit_giveaway', guild_id=g.guild_id, uuid=giveaway['uuid']) }}" class="btn btn-primary btn-sm">Edit</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>User Dashboard</title>
|
<title>User Dashboard</title>
|
||||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% include 'navigation.html' %}
|
{% include 'navigation.html' %}
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
@@ -43,14 +41,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Additional Information or Links -->
|
<!-- Additional Options -->
|
||||||
<div class="row mt-5">
|
<div class="row mt-5">
|
||||||
<div class="col-12 text-center">
|
<div class="col-12 text-center">
|
||||||
<h5>Additional Options</h5>
|
<h5>Your Giveaways</h5>
|
||||||
<a href="{{ url_for('server_giveaways', guild_id=g.guild_id) }}" class="btn btn-info mt-3">View Server Giveaways</a>
|
<a href="{{ url_for('user_giveaways', guild_id=g.guild_id) }}" class="btn btn-info mt-3">View Won Giveaways</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user