Compare commits
2 Commits
f275615f3c
...
ac343cef67
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac343cef67 | ||
|
|
af308535fe |
41
app.py
41
app.py
@@ -51,13 +51,34 @@ CONFIG_FILE = os.path.join(BASE_DIR, "config.json") # Persistente Konfiguration
|
|||||||
USERS_FILE = os.path.join(BASE_DIR, "users.json") # User-Datenbank
|
USERS_FILE = os.path.join(BASE_DIR, "users.json") # User-Datenbank
|
||||||
HISTORY_FILE = os.path.join(BASE_DIR, "history.json") # Aktivitätsverlauf
|
HISTORY_FILE = os.path.join(BASE_DIR, "history.json") # Aktivitätsverlauf
|
||||||
|
|
||||||
APP_VERSION = "6.2.2"
|
APP_VERSION = "6.2.3"
|
||||||
UPLOAD_EXTENSIONS = {".jpg", ".jpeg", ".png", ".mp4"}
|
UPLOAD_EXTENSIONS = {".jpg", ".jpeg", ".png", ".mp4"}
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = "CHANGE_THIS_SECRET!!!"
|
app.secret_key = "CHANGE_THIS_SECRET!!!"
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1)
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1)
|
||||||
|
|
||||||
|
def remember_site(site):
|
||||||
|
"""Merkt den zuletzt besuchten Standort in der Session."""
|
||||||
|
if site:
|
||||||
|
session["last_site"] = site
|
||||||
|
|
||||||
|
|
||||||
|
def current_site_for(cfg, user=None):
|
||||||
|
"""Standort für Seiten ohne eigenen Standortbezug (Dashboard, Hilfe,
|
||||||
|
User-Verwaltung, MFA).
|
||||||
|
|
||||||
|
Nimmt den zuletzt besuchten Standort, sonst den ersten *zugänglichen*.
|
||||||
|
Ohne das springt die Standortanzeige im Header auf den global ersten
|
||||||
|
Standort - und der "Übersicht"-Link führt anschliessend dorthin statt
|
||||||
|
zurück zu dem Standort, von dem man kam."""
|
||||||
|
sites = get_accessible_sites(cfg, user) if (user is not None and user.is_authenticated) else get_site_list(cfg)
|
||||||
|
letzter = session.get("last_site")
|
||||||
|
if letzter in sites:
|
||||||
|
return letzter
|
||||||
|
return sites[0] if sites else ""
|
||||||
|
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_globals():
|
def inject_globals():
|
||||||
"""Stellt globale Template-Variablen für Header/Footer bereit."""
|
"""Stellt globale Template-Variablen für Header/Footer bereit."""
|
||||||
@@ -67,7 +88,7 @@ def inject_globals():
|
|||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
site_list = get_accessible_sites(cfg, current_user)
|
site_list = get_accessible_sites(cfg, current_user)
|
||||||
current_site_val = get_site_list(cfg)[0] if get_site_list(cfg) else ""
|
current_site_val = current_site_for(cfg, current_user)
|
||||||
else:
|
else:
|
||||||
site_list = get_site_list(cfg)
|
site_list = get_site_list(cfg)
|
||||||
current_site_val = site_list[0] if site_list else ""
|
current_site_val = site_list[0] if site_list else ""
|
||||||
@@ -863,11 +884,11 @@ def mfa_setup():
|
|||||||
save_users(users_data)
|
save_users(users_data)
|
||||||
add_history_entry("mfa_enabled", f"User '{email}' hat MFA aktiviert", email)
|
add_history_entry("mfa_enabled", f"User '{email}' hat MFA aktiviert", email)
|
||||||
return render_template("mfa_recovery.html", codes=recovery, email=email,
|
return render_template("mfa_recovery.html", codes=recovery, email=email,
|
||||||
site_list=site_list, current_site=site_list[0] if site_list else "",
|
site_list=site_list, current_site=current_site_for(cfg, current_user),
|
||||||
brand_subtitle="MFA", site_dropdown_url_prefix="/admin/")
|
brand_subtitle="MFA", site_dropdown_url_prefix="/admin/")
|
||||||
return render_template("mfa_setup.html", error="Code ungültig. Bitte versuche es erneut.",
|
return render_template("mfa_setup.html", error="Code ungültig. Bitte versuche es erneut.",
|
||||||
email=email, secret=secret, qr_data=None,
|
email=email, secret=secret, qr_data=None,
|
||||||
site_list=site_list, current_site=site_list[0] if site_list else "",
|
site_list=site_list, current_site=current_site_for(cfg, current_user),
|
||||||
brand_subtitle="MFA", site_dropdown_url_prefix="/admin/")
|
brand_subtitle="MFA", site_dropdown_url_prefix="/admin/")
|
||||||
|
|
||||||
uri = totp.provisioning_uri(name=email, issuer_name="CANCOM Signage")
|
uri = totp.provisioning_uri(name=email, issuer_name="CANCOM Signage")
|
||||||
@@ -879,7 +900,7 @@ def mfa_setup():
|
|||||||
return render_template("mfa_setup.html", error=None if not error_param else "Passwort ist falsch",
|
return render_template("mfa_setup.html", error=None if not error_param else "Passwort ist falsch",
|
||||||
email=email, secret=secret, qr_data=qr_b64,
|
email=email, secret=secret, qr_data=qr_b64,
|
||||||
recovered=recovered, disabled=disabled,
|
recovered=recovered, disabled=disabled,
|
||||||
site_list=site_list, current_site=site_list[0] if site_list else "",
|
site_list=site_list, current_site=current_site_for(cfg, current_user),
|
||||||
brand_subtitle="MFA", site_dropdown_url_prefix="/admin/")
|
brand_subtitle="MFA", site_dropdown_url_prefix="/admin/")
|
||||||
|
|
||||||
|
|
||||||
@@ -947,6 +968,8 @@ def add_customer():
|
|||||||
if site and not current_user.can_access_site(site):
|
if site and not current_user.can_access_site(site):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
|
remember_site(site)
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
customer_names = [
|
customer_names = [
|
||||||
request.form.get("customer_name_1", "").strip(),
|
request.form.get("customer_name_1", "").strip(),
|
||||||
@@ -1404,6 +1427,7 @@ def admin(site):
|
|||||||
Admin-Dashboard für einen Standort.
|
Admin-Dashboard für einen Standort.
|
||||||
Zeigt alle Screens als Cards mit Tabler-Tabs (Playlist, Einstellungen, Medien).
|
Zeigt alle Screens als Cards mit Tabler-Tabs (Playlist, Einstellungen, Medien).
|
||||||
"""
|
"""
|
||||||
|
remember_site(site)
|
||||||
cfg = load_config()
|
cfg = load_config()
|
||||||
|
|
||||||
site_list = get_accessible_sites(cfg, current_user)
|
site_list = get_accessible_sites(cfg, current_user)
|
||||||
@@ -1545,6 +1569,7 @@ def admin(site):
|
|||||||
@site_access_required
|
@site_access_required
|
||||||
def admin_priority(site):
|
def admin_priority(site):
|
||||||
"""Zeigt die Priority-Playlist-Seite mit Tabs (Playlist + Medien)."""
|
"""Zeigt die Priority-Playlist-Seite mit Tabs (Playlist + Medien)."""
|
||||||
|
remember_site(site)
|
||||||
cfg = load_config()
|
cfg = load_config()
|
||||||
site_list = get_accessible_sites(cfg, current_user)
|
site_list = get_accessible_sites(cfg, current_user)
|
||||||
priority_files = load_priority_files(site)
|
priority_files = load_priority_files(site)
|
||||||
@@ -2087,7 +2112,7 @@ def admin_dashboard():
|
|||||||
superuser_trend=superuser_trend,
|
superuser_trend=superuser_trend,
|
||||||
history=history,
|
history=history,
|
||||||
site_list=get_accessible_sites(cfg, current_user),
|
site_list=get_accessible_sites(cfg, current_user),
|
||||||
current_site=get_site_list(cfg)[0] if get_site_list(cfg) else "",
|
current_site=current_site_for(cfg, current_user),
|
||||||
version=APP_VERSION,
|
version=APP_VERSION,
|
||||||
year=datetime.now().year,
|
year=datetime.now().year,
|
||||||
hostname=os.uname().nodename,
|
hostname=os.uname().nodename,
|
||||||
@@ -2103,7 +2128,7 @@ def admin_help():
|
|||||||
return render_template(
|
return render_template(
|
||||||
"help.html",
|
"help.html",
|
||||||
site_list=get_accessible_sites(cfg, current_user),
|
site_list=get_accessible_sites(cfg, current_user),
|
||||||
current_site=get_site_list(cfg)[0] if get_site_list(cfg) else "",
|
current_site=current_site_for(cfg, current_user),
|
||||||
version=APP_VERSION,
|
version=APP_VERSION,
|
||||||
year=datetime.now().year,
|
year=datetime.now().year,
|
||||||
hostname=os.uname().nodename,
|
hostname=os.uname().nodename,
|
||||||
@@ -2136,7 +2161,7 @@ def admin_users():
|
|||||||
"user_list.html",
|
"user_list.html",
|
||||||
users=sorted(users_list, key=lambda u: (u["last_name"].lower(), u["first_name"].lower())),
|
users=sorted(users_list, key=lambda u: (u["last_name"].lower(), u["first_name"].lower())),
|
||||||
site_list=get_accessible_sites(cfg, current_user),
|
site_list=get_accessible_sites(cfg, current_user),
|
||||||
current_site=get_site_list(cfg)[0] if get_site_list(cfg) else "",
|
current_site=current_site_for(cfg, current_user),
|
||||||
version=APP_VERSION,
|
version=APP_VERSION,
|
||||||
year=datetime.now().year,
|
year=datetime.now().year,
|
||||||
hostname=os.uname().nodename,
|
hostname=os.uname().nodename,
|
||||||
|
|||||||
Reference in New Issue
Block a user