From d5a92d187f327d0e1b74181d51037141ad51ffcb Mon Sep 17 00:00:00 2001 From: Till Tomczak Date: Wed, 19 Feb 2025 21:14:02 +0100 Subject: [PATCH] wallpaper fix --- Dashboard_V2/app.py | 24 +- Dashboard_V2/templates/admin.html | 304 ++++++++++++++------------ Dashboard_V2/templates/base.html | 10 +- Dashboard_V2/templates/dashboard.html | 2 +- clickcandit.db | Bin 40960 -> 40960 bytes 5 files changed, 195 insertions(+), 145 deletions(-) diff --git a/Dashboard_V2/app.py b/Dashboard_V2/app.py index 7cd888e..1b816ef 100644 --- a/Dashboard_V2/app.py +++ b/Dashboard_V2/app.py @@ -564,12 +564,32 @@ def get_settings(): else: # Falls noch kein Datensatz existiert return jsonify({ - "wallpaper": "1.png", + "wallpaper": "24.png", "city": "", "show_forecast": False, "bookmarks": [] }) +@app.context_processor +def inject_wallpaper(): + """ + Dieser Context Processor wird bei jedem Template-Aufruf ausgeführt. + Ermittelt das Wallpaper des eingeloggten Benutzers (falls eingeloggt) + und stellt es allen Templates als Variable 'WALLPAPER_URL' bereit. + """ + if 'user_id' in session: + db = get_db() + row = db.execute("SELECT wallpaper FROM user_settings WHERE user_id=?", (session['user_id'],)).fetchone() + if row and row['wallpaper']: + # Bsp: row['wallpaper'] könnte '19.png' o. ä. sein + return { + "WALLPAPER_URL": url_for('static', filename=row['wallpaper']) + } + # Fallback: Wenn User nicht eingeloggt oder kein Wallpaper gesetzt + return { + "WALLPAPER_URL": url_for('static', filename='24.png') + } + @app.route('/save_settings', methods=['POST']) def save_settings(): """ @@ -580,7 +600,7 @@ def save_settings(): return jsonify({"success": False, "error": "not logged in"}), 403 data = request.get_json() - wallpaper = data.get('wallpaper', '1.png') + wallpaper = data.get('wallpaper', '24.png') city = data.get('city', '') show_forecast = data.get('show_forecast', False) bookmarks_list = data.get('bookmarks', []) diff --git a/Dashboard_V2/templates/admin.html b/Dashboard_V2/templates/admin.html index 1cfc269..8efc6ab 100644 --- a/Dashboard_V2/templates/admin.html +++ b/Dashboard_V2/templates/admin.html @@ -1,148 +1,178 @@ - + - - + + Admin-Bereich - - -
-

Admin-Bereich

- + +
+

Admin-Bereich

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

Neuen Benutzer anlegen

-
-
- - -
-
- - -
-
-
+ +
+ + + Zurück zum Dashboard +
- + \ No newline at end of file diff --git a/Dashboard_V2/templates/base.html b/Dashboard_V2/templates/base.html index bc7999d..1ee70b2 100644 --- a/Dashboard_V2/templates/base.html +++ b/Dashboard_V2/templates/base.html @@ -5,12 +5,12 @@ {% block title %}Meine App{% endblock %} - + - + - + \ No newline at end of file diff --git a/Dashboard_V2/templates/dashboard.html b/Dashboard_V2/templates/dashboard.html index b3c6c05..e6f6d2a 100644 --- a/Dashboard_V2/templates/dashboard.html +++ b/Dashboard_V2/templates/dashboard.html @@ -85,7 +85,7 @@

Zeiterfassung

-