From 2558312e1de98356597e2df3b0d2945499ccd86a Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 14 Nov 2025 18:12:30 -0500 Subject: Fix untypable circular import --- Biz/PodcastItLater/UI.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Biz/PodcastItLater/UI.py b/Biz/PodcastItLater/UI.py index 4844d67..8959d4e 100644 --- a/Biz/PodcastItLater/UI.py +++ b/Biz/PodcastItLater/UI.py @@ -127,6 +127,16 @@ def create_bootstrap_js() -> html.script: ) +def is_admin(user: dict[str, typing.Any] | None) -> bool: + """Check if user is an admin based on email whitelist.""" + if not user: + return False + admin_emails = ["ben@bensima.com", "demo@example.com"] + return user.get("email", "").lower() in [ + email.lower() for email in admin_emails + ] + + class PageLayoutAttrs(Attrs): """Attributes for PageLayout component.""" @@ -144,8 +154,6 @@ class PageLayout(Component[AnyChildren, PageLayoutAttrs]): current_page: str, ) -> html.nav: """Render navigation bar.""" - # Import here to avoid circular dependency - import Biz.PodcastItLater.Core as Core # noqa: PLC0415 # type: ignore[import-untyped] def is_active(page: str) -> bool: return current_page == page @@ -258,7 +266,7 @@ class PageLayout(Component[AnyChildren, PageLayoutAttrs]): ), classes=["nav-item", "dropdown"], ) - if user and Core.is_admin(user) + if user and is_admin(user) else html.span(), classes=["navbar-nav"], ), -- cgit v1.2.3