diff options
Diffstat (limited to 'Biz/PodcastItLater/UI.py')
| -rw-r--r-- | Biz/PodcastItLater/UI.py | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/Biz/PodcastItLater/UI.py b/Biz/PodcastItLater/UI.py index 4650708..bdf7a5b 100644 --- a/Biz/PodcastItLater/UI.py +++ b/Biz/PodcastItLater/UI.py @@ -6,6 +6,7 @@ Common UI components and utilities shared across web pages. # : out podcastitlater-ui # : dep ludic +import Biz.PodcastItLater.Core as Core import ludic.html as html import typing from ludic.attrs import Attrs @@ -127,15 +128,6 @@ 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", "admin@example.com"] - return user.get("email", "").lower() in [ - email.lower() for email in admin_emails - ] - class PageLayoutAttrs(Attrs): """Attributes for PageLayout component.""" @@ -318,7 +310,7 @@ class PageLayout(Component[AnyChildren, PageLayoutAttrs]): ), classes=["nav-item", "dropdown"], ) - if user and is_admin(user) + if user and Core.is_admin(user) else html.span(), classes=["navbar-nav"], ), @@ -435,12 +427,7 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): limit_text = "Unlimited" if article_limit is None else str(article_limit) return PageLayout( - user=user, - current_page="account", - page_title="Account - PodcastItLater", - error=None, - meta_tags=[], - children=[ + html.div( html.div( html.div( html.div( @@ -448,8 +435,8 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): html.h2( html.i( classes=[ - "bi", - "bi-person-circle", + "bi", + "bi-person-circle", "me-2" ] ), @@ -481,8 +468,8 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): plan_tier.title(), classes=[ "badge", - "bg-success" - if is_paid + "bg-success" + if is_paid else "bg-secondary", "ms-2", ], @@ -527,9 +514,9 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): type="submit", classes=["btn", "btn-outline-primary"], ), - method="POST", + method="post", action=portal_url, - ) if is_paid and portal_url else + ) if is_paid and portal_url else html.a( html.i(classes=["bi", "bi-star-fill", "me-2"]), "Upgrade to Pro", @@ -548,8 +535,8 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): html.button( html.i( classes=[ - "bi", - "bi-box-arrow-right", + "bi", + "bi-box-arrow-right", "me-2" ] ), @@ -558,7 +545,7 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): classes=["btn", "btn-outline-danger"], ), action="/logout", - method="POST", + method="post", ), classes=["border-top", "pt-4"], ), @@ -570,7 +557,12 @@ class AccountPage(Component[AnyChildren, AccountPageAttrs]): ), classes=["row"], ), - ], + ), + user=user, + current_page="account", + page_title="Account - PodcastItLater", + error=None, + meta_tags=[], ) @@ -589,12 +581,7 @@ class PricingPage(Component[AnyChildren, PricingPageAttrs]): current_tier = user.get("plan_tier", "free") if user else "free" return PageLayout( - user=user, - current_page="pricing", - page_title="Pricing - PodcastItLater", - error=None, - meta_tags=[], - children=[ + html.div( html.div( html.h2("Simple Pricing", classes=["text-center", "mb-5"]), html.div( @@ -714,5 +701,10 @@ class PricingPage(Component[AnyChildren, PricingPageAttrs]): ), classes=["container", "py-3"], ), - ], + ), + user=user, + current_page="pricing", + page_title="Pricing - PodcastItLater", + error=None, + meta_tags=[], ) |
