diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-14 18:12:30 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-14 18:12:30 -0500 |
| commit | 2558312e1de98356597e2df3b0d2945499ccd86a (patch) | |
| tree | 1400c583edf84eb1785ee7f37cc426191b73aeee /Biz | |
| parent | bffdc005275bf74cde864dabcfafec497dcf0013 (diff) | |
Fix untypable circular import
Diffstat (limited to 'Biz')
| -rw-r--r-- | Biz/PodcastItLater/UI.py | 14 |
1 files 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"], ), |
