modified: app.py
modified: templates/server_admin_dashboard.html
This commit is contained in:
42
app.py
42
app.py
@@ -300,7 +300,10 @@ def server_admin_dashboard(guild_id):
|
||||
connection = get_db_connection()
|
||||
cursor = connection.cursor(dictionary=True)
|
||||
|
||||
# Hole die Giveaways für den spezifischen Server
|
||||
# Hole die Benutzer und Giveaways für den spezifischen Server
|
||||
cursor.execute("SELECT * FROM user_data WHERE guild_id = %s", (guild_id,))
|
||||
users = cursor.fetchall()
|
||||
|
||||
cursor.execute("SELECT * FROM giveaway_data WHERE guild_id = %s", (guild_id,))
|
||||
giveaways = cursor.fetchall()
|
||||
|
||||
@@ -312,13 +315,44 @@ def server_admin_dashboard(guild_id):
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
g.guild_id = guild_id
|
||||
g.guild_name = guild_name
|
||||
return render_template("server_admin_dashboard.html", giveaways=giveaways, guild_id=guild_id, guild_name=guild_name)
|
||||
return render_template("server_admin_dashboard.html",
|
||||
users=users, giveaways=giveaways,
|
||||
guild_id=guild_id, guild_name=guild_name)
|
||||
|
||||
flash("You do not have permission to access this server's admin dashboard.", "danger")
|
||||
return redirect(url_for("user_landing_page"))
|
||||
|
||||
@app.route("/edit_user/<int:guild_id>/<int:user_id>", methods=["GET", "POST"])
|
||||
def edit_user(guild_id, user_id):
|
||||
"""Bearbeitet Benutzerinformationen für einen bestimmten Server."""
|
||||
if is_server_admin(guild_id):
|
||||
connection = get_db_connection()
|
||||
cursor = connection.cursor(dictionary=True)
|
||||
|
||||
if request.method == "POST":
|
||||
points = request.form["points"]
|
||||
level = request.form["level"]
|
||||
permission = request.form["permission"]
|
||||
|
||||
cursor.execute("""
|
||||
UPDATE user_data
|
||||
SET points = %s, level = %s, permission = %s
|
||||
WHERE guild_id = %s AND user_id = %s
|
||||
""", (points, level, permission, guild_id, user_id))
|
||||
connection.commit()
|
||||
|
||||
flash("User data updated successfully!", "success")
|
||||
return redirect(url_for("server_admin_dashboard", guild_id=guild_id))
|
||||
|
||||
cursor.execute("SELECT * FROM user_data WHERE guild_id = %s AND user_id = %s", (guild_id, user_id))
|
||||
user = cursor.fetchone()
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
return render_template("edit_user.html", user=user, guild_id=guild_id)
|
||||
return redirect(url_for("landing_page"))
|
||||
|
||||
|
||||
@app.route("/ban_user/<int:guild_id>/<int:user_id>")
|
||||
def ban_user(guild_id, user_id):
|
||||
"""Banned einen Benutzer auf einem spezifischen Server."""
|
||||
|
||||
@@ -3,28 +3,68 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Server Admin Dashboard</title>
|
||||
<title>Server Admin Dashboard - {{ guild_name }}</title>
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
.table-container {
|
||||
max-height: 400px; /* Begrenzte Höhe für die Tabellen */
|
||||
overflow-y: auto;
|
||||
}
|
||||
h2 {
|
||||
color: #343a40;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% include 'navigation.html' %}
|
||||
<div class="container mt-5">
|
||||
<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>
|
||||
<h2 class="text-center">Server Admin Dashboard for {{ guild_name }}</h2>
|
||||
<p class="text-center text-muted">Manage server-specific settings for server <strong>{{ guild_id }}</strong>.</p>
|
||||
|
||||
<!-- Giveaway Management -->
|
||||
<div class="card mt-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Giveaway Management</h5>
|
||||
<p class="card-text">Manage and view all active giveaways for this server.</p>
|
||||
<table class="table table-bordered mt-4">
|
||||
<!-- User Management Section -->
|
||||
<div class="mt-5">
|
||||
<h4>User Management</h4>
|
||||
<div class="table-container">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Discord ID</th>
|
||||
<th>Points</th>
|
||||
<th>Level</th>
|
||||
<th>Role</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.user_id }}</td>
|
||||
<td>{{ user.points }}</td>
|
||||
<td>{{ user.level }}</td>
|
||||
<td>{{ user.permission }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('edit_user', guild_id=guild_id, user_id=user.user_id) }}" class="btn btn-primary btn-sm">Edit</a>
|
||||
<a href="{{ url_for('ban_user', guild_id=guild_id, user_id=user.user_id) }}" class="btn btn-danger btn-sm">Ban</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Giveaway Management Section -->
|
||||
<div class="mt-5">
|
||||
<h4>Giveaway Management</h4>
|
||||
<div class="table-container">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Platform</th>
|
||||
<th>Winner</th>
|
||||
<th>Winner ID</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -41,7 +81,8 @@
|
||||
{% 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>
|
||||
<a href="{{ url_for('edit_giveaway', guild_id=guild_id, uuid=giveaway.uuid) }}" class="btn btn-primary btn-sm">Edit</a>
|
||||
<a href="{{ url_for('delete_giveaway', guild_id=guild_id, uuid=giveaway.uuid) }}" class="btn btn-danger btn-sm">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user