From 6666f9e9fe761ec30b0bf335bfa1ad70f659a766 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Tue, 24 Dec 2024 13:38:56 +0100 Subject: [PATCH] improve layout templating --- frontend.py | 31 ++++++++++++++----------------- templates/layout.jinja | 12 +++++------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/frontend.py b/frontend.py index cb500eb..2a705b2 100644 --- a/frontend.py +++ b/frontend.py @@ -43,6 +43,7 @@ get_user_assets, is_within_timeframe, login_required, + DEFAULT_SSO_PROVIDER, ) from util.redis import REDIS from util.sso import SSO_CONFIG @@ -144,27 +145,23 @@ def before_request(): @app.context_processor -def login_providers(): - result = {} - - for provider, config in CONFIG["oauth2_providers"].items(): - result[provider] = SSO_CONFIG[provider]["display_name"] - - return {"login_providers": result} - - -@app.context_processor -def start_time_alert(): - # if g.user is set, the user was successfully logged in (see above) - if g.userid: - return {"start_time": None} +def layout_context_variables(): + result = { + "default_sso_provider": DEFAULT_SSO_PROVIDER, + "source_url": CONFIG["FAQ"]["SOURCE"], + "sso_providers": {}, + "start_time": {}, + } start_time = datetime.fromtimestamp(CONFIG["TIME_MIN"], timezone.utc) - if start_time < datetime.now(timezone.utc): - return {"start_time": None} + for provider, config in CONFIG["oauth2_providers"].items(): + result["sso_providers"][provider] = SSO_CONFIG[provider]["display_name"] + + if not g.userid and start_time > datetime.now(timezone.utc): + result["start_time"] = start_time.strftime("%F %T") - return {"start_time": start_time.strftime("%F %T")} + return result @app.route("/login/") diff --git a/templates/layout.jinja b/templates/layout.jinja index 733b0d1..0539e33 100644 --- a/templates/layout.jinja +++ b/templates/layout.jinja @@ -38,8 +38,8 @@
  • Logout
  • {% else %} - {% for slug, name in login_providers.items() %} -
  • Login / Sign up using {{ name }}
  • + {% for slug, name in sso_providers.items() %} +
  • Login / Sign up using {{ name }}
  • {% endfor %} {% endif %} @@ -61,11 +61,9 @@

    - Share your projects via info-beamer. - FAQ / Contact. -

    -

    - Screens run info-beamer on Raspberry Pis. + FAQ / Contact | + This project is open source | + Screens run info-beamer on Raspberry Pis.