From 37576585397a7cc6d688e6fe2c4d85342fcc4158 Mon Sep 17 00:00:00 2001 From: Till Tomczak Date: Wed, 19 Feb 2025 21:39:15 +0100 Subject: [PATCH] =?UTF-8?q?letzte=20korrekturen=20und=20aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dashboard_V2/app.py | 45 +++++++ Dashboard_V2/templates/admin.html | 180 +++++++++++++------------- Dashboard_V2/templates/dashboard.html | 29 +++-- clickcandit.db | Bin 40960 -> 0 bytes 4 files changed, 152 insertions(+), 102 deletions(-) delete mode 100644 clickcandit.db diff --git a/Dashboard_V2/app.py b/Dashboard_V2/app.py index 03f53fd..338b08a 100644 --- a/Dashboard_V2/app.py +++ b/Dashboard_V2/app.py @@ -546,6 +546,50 @@ def dashboard(): # SUPPORT & SETTINGS ROUTEN (Aus V1) # ------------------------------------------------------------ +@app.route('/delete_notification/', methods=['POST']) +def delete_notification(notif_id): + if 'user_id' not in session: + flash("Bitte melde dich an!", "red") + return redirect(url_for('login')) + + user_id = session['user_id'] + db = get_db() + + # Prüfen, ob die Notification existiert + row = db.execute(""" + SELECT user_id + FROM notifications + WHERE id=? + """, (notif_id,)).fetchone() + + if not row: + flash("Benachrichtigung existiert nicht.", "red") + return redirect(url_for('dashboard')) + + # Wenn user_id = NULL => globale Notification + # Du kannst selbst definieren, ob jeder sie löschen darf oder nur Admin + # Hier: Jeder kann globale Notification löschen, wenn er sie sieht. + # Oder du sagst: Nur Admin kann globale Notis löschen -> if row['user_id'] is None and not is_admin(): ... + if row['user_id'] is None: + # Optional: Nur Admin löschen + if not is_admin(): + flash('Nicht erlaubt', 'red') + return redirect(url_for('dashboard')) + pass + else: + # Wenn es eine user-spezifische Notification ist: user_id muss übereinstimmen + if row['user_id'] != user_id: + flash("Keine Berechtigung, diese Benachrichtigung zu löschen.", "red") + return redirect(url_for('dashboard')) + + # Benachrichtigung löschen + db.execute("DELETE FROM notifications WHERE id=?", (notif_id,)) + db.commit() + + flash("Benachrichtigung gelöscht!", "green") + return redirect(url_for('dashboard')) + + @app.route('/send_support_message', methods=['POST']) def send_support_message(): """ @@ -665,6 +709,7 @@ def add_bookmarks_multi(): if not target_list: flash("Bitte mindestens einen Benutzer auswählen!", "red") return redirect(url_for('admin_panel')) + icon = request.form.get('icon_class') db = get_db() for uid in target_list: diff --git a/Dashboard_V2/templates/admin.html b/Dashboard_V2/templates/admin.html index d2a5306..a0c0efb 100644 --- a/Dashboard_V2/templates/admin.html +++ b/Dashboard_V2/templates/admin.html @@ -1,154 +1,150 @@ - {% extends "base.html" %} {% block title %} Admin-Bereich {% endblock title %} {% block content %} -
-

Admin-Bereich

+
+

Admin-Bereich

{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} -
+
{{ message }}
{% endfor %} {% endif %} {% endwith %} - -
+ +
-
-

Neuen Benutzer anlegen

-
-
- - -
-
- - -
-
- - Als Admin markieren -
- +
+

Neuen Benutzer anlegen

+ +
+ + +
+
+ + +
+
+ + Als Admin markieren +
+
-
-

Benutzerverwaltung

- - - - - - - - - - - {% for u in users %} - - - - - - - {% endfor %} - -
IDUsernameAdmin?Aktion
{{ u.id }}{{ u.username }}{{ 'Ja' if u.is_admin else 'Nein' }} - - - Lesezeichen - - -
- -
-
+
+

Benutzerverwaltung

+
+ + + + + + + + + + + {% for u in users %} + + + + + + + {% endfor %} + +
IDUsernameAdmin?Aktion
{{ u.id }}{{ u.username }}{{ 'Ja' if u.is_admin else 'Nein' }} + + Lesezeichen + +
+ +
+
+
-
-

Benachrichtigung erstellen

-
+
+

Benachrichtigung erstellen

+
- - + +
-

Für welche Benutzer?

- +

Für welche Benutzer?

- {% for u in users %} -
-
-
-

Lesezeichen-Verwaltung

-
-

Für welche Benutzer soll das Lesezeichen gelten?

+
+

Lesezeichen-Verwaltung

+ +

Für welche Benutzer soll das Lesezeichen gelten?

{% for u in users %} -
-
- - + +
- - + +
- - + +
- - {% if single_user and bookmarks %} -

Lesezeichen für {{ single_user.username }}:

-
+ class="inline-block bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded shadow transition duration-200 mt-8"> Zurück zum Dashboard
diff --git a/Dashboard_V2/templates/dashboard.html b/Dashboard_V2/templates/dashboard.html index e6f6d2a..ef8b6ba 100644 --- a/Dashboard_V2/templates/dashboard.html +++ b/Dashboard_V2/templates/dashboard.html @@ -24,15 +24,15 @@
-
- + - -
@@ -68,12 +68,21 @@

Benachrichtigungen

{% if notifications %}
    - {% for note in notifications %} -
  • - {{ note.message }}
    - {{ note.created_at }} -
  • - {% endfor %} + {% for note in notifications %} +
  • +
    + {{ note.message }}
    + {{ note.created_at }} +
    +
    + +
    +
  • + {% endfor %}
{% else %}

Keine neuen Benachrichtigungen

diff --git a/clickcandit.db b/clickcandit.db deleted file mode 100644 index ae91edfa314666c09d73876b0054b1fb8e5455ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40960 zcmeI*&2QUe90zbaX`7~ydQ6%kgsMG6f$=VJ&u}$Acas2++{`~C6ej3|d zzp-owlr&tgWduawPH{ZXT_S|zxYMkeU`;orSjR}Whqd{h?&o!$=H~0~WrV-E^yoL- z` z)q7^GuIi+^vAjGuswzi$bjel{fctE)9_=~^}Pn0>mzIa1TE zYBjC8sI8N5m_KVLk47cPms^pH;|6xaHjTh` z9Y5AH7PEz0C2haXGI(}s>&`01)+e|7#Yif9_ALK!DPlc1I~;V3 z#yAfKzbwi_j>EtXnn$X2yyj7`w&^-`vuXHGPl4TC{n?qhVfdtB%yl>RWfrq*$+7JD z^Zd<7-@n~t_0GCaZ+EC;(!So2SS0#J&N@bmUSM^{k^pMO%iwAJ3sXxM8(yXW*izZx7EU#u~Ug-ctld-E3cO>d_iloffQsFu~TbZ*(}T(4dKe5dMuqUO!}opYwO z(8yC-G$}PoMyZ%DD3(Ia1zHj}sY;7^*;18KL$!*gDV6e@VxGzirYeh;Wm>YSE?A~f zkc@`XFfCEZ7gQzRkPDWPXBjpMGLZcOU8S6Q>fa z)*s&X&mOnfe{gi1PiCVbepvrc2)}T`pX>_>0uX=z1Rwwb2tWV=5P$##AOL~aQeZMM z#--1k$pq|OHeoZ#$NR(je^RhH;aA}+)a694D0{wrT<6}fB*y_009U<00Izz z00bZa0SLUo0%8517ry7%2MGcYfB*y_009U<00Izz00bZafmc-EgXn(#N~QnTf2k~~ zWw|)7$f~3kdv7?9%Cb}z^Yfx2Dso}J{{Ms%p1h(Ph}D7s1Rwwb2tWV=5P$##AOHaf yK;Xp%GVH$=rr*tsXJm1{?QG%x{}(6391ws21Rwwb2tWV=5P$##AOL~aP2eAj7+25$