letzte korrekturen und aufräumen
This commit is contained in:
@@ -546,6 +546,50 @@ def dashboard():
|
||||
# SUPPORT & SETTINGS ROUTEN (Aus V1)
|
||||
# ------------------------------------------------------------
|
||||
|
||||
@app.route('/delete_notification/<int:notif_id>', 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:
|
||||
|
||||
Reference in New Issue
Block a user