diff --git a/Dashboard_V2/app.py b/Dashboard_V2/app.py index 35bf530..7cd888e 100644 --- a/Dashboard_V2/app.py +++ b/Dashboard_V2/app.py @@ -32,7 +32,6 @@ def close_connection(exception): def init_db(): with app.app_context(): db = get_db() - # Users db.execute(""" CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -42,7 +41,6 @@ def init_db(): is_admin INTEGER DEFAULT 0 ); """) - # Bookmarks db.execute(""" CREATE TABLE IF NOT EXISTS bookmarks ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -53,11 +51,10 @@ def init_db(): FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE ); """) - # Notifications db.execute(""" CREATE TABLE IF NOT EXISTS notifications ( id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER, -- NULL = für alle + user_id INTEGER, message TEXT NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, is_read INTEGER DEFAULT 0 @@ -71,7 +68,6 @@ def init_db(): FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE ); """) - # Time Tracking db.execute(""" CREATE TABLE IF NOT EXISTS time_entries ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -82,7 +78,6 @@ def init_db(): FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE ); """) - # Settings (OPTIONAL, falls du globale User-Einstellungen abspeichern willst) db.execute(""" CREATE TABLE IF NOT EXISTS user_settings ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -94,19 +89,8 @@ def init_db(): FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE ); """) - db.execute(""" - CREATE TABLE IF NOT EXISTS settings ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL, - wallpaper TEXT DEFAULT '19.png', - city TEXT DEFAULT 'Berlin', - show_forecast INTEGER DEFAULT 1, - bookmarks TEXT DEFAULT '[]', - FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE - ); - """) db.commit() - + # ------------------------------------------------------------ # HILFSFUNKTIONEN # ------------------------------------------------------------ @@ -204,7 +188,7 @@ def login(): flash("Benutzername oder Passwort falsch!", "red") return render_template('login.html') -@app.route('/logout', methods=['POST']) +@app.route('/logout', methods=['GET', 'POST']) def logout(): session.clear() flash("Erfolgreich abgemeldet!", "green") diff --git a/Dashboard_V2/templates/admin.html b/Dashboard_V2/templates/admin.html index 49aa21e..1cfc269 100644 --- a/Dashboard_V2/templates/admin.html +++ b/Dashboard_V2/templates/admin.html @@ -1,149 +1,148 @@ -{% extends "base.html" %} -{% block title %}Admin-Bereich{% endblock %} - -{% block content %} -
| ID | +Username | +Admin? | +Aktion | +
|---|---|---|---|
| {{ u.id }} | +{{ u.username }} | +{{ 'Ja' if u.is_admin else 'Nein' }} | ++ {% if u.id != session.user_id %} + + {% else %} + [Eigener Account] + {% endif %} + | +
| ID | -Username | -Admin? | -- |
|---|---|---|---|
| {{ u.id }} | -{{ u.username }} | -{{ 'Ja' if u.is_admin else 'Nein' }} | -- {% if u.id != session.user_id %} - - {% else %} - [Eigener Account] - {% endif %} - - Lesezeichen - - | -
{{ message }}