summaryrefslogtreecommitdiff
path: root/Biz/PodcastItLater/Core.py
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-09 14:28:39 -0500
committerBen Sima <ben@bsima.me>2025-11-09 14:28:39 -0500
commitc76c83987fae48c995e605d947aea72d513ee7cd (patch)
tree751f57da62b123218cdc7380aff9befd5317ea92 /Biz/PodcastItLater/Core.py
parent253fdc93cb3e79983de69e0875c69efa77660aac (diff)
feat(PodcastItLater): Apply Bootstrap 5 UI and fix dev login
- Apply Bootstrap 5 CSS and icons to all pages (Web.py, Admin.py) - Convert all components to use Bootstrap classes instead of inline styles - Add dev mode banner showing demo@example.com for instant login - Implement secure demo account (demo@example.com) with auto-approval - Fix HTMX loading issue when load_styles=False - Update Database.create_user() to accept optional status parameter - Add Bootstrap tables, cards, badges, and button groups throughout - All tests passing Completes task t-144drAE Amp-Thread-ID: https://ampcode.com/threads/T-8feaca83-dcc2-46cb-8f71-d0785960a2f7 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Biz/PodcastItLater/Core.py')
-rw-r--r--Biz/PodcastItLater/Core.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/Biz/PodcastItLater/Core.py b/Biz/PodcastItLater/Core.py
index 0ca945c..b7b6ed9 100644
--- a/Biz/PodcastItLater/Core.py
+++ b/Biz/PodcastItLater/Core.py
@@ -576,13 +576,21 @@ class Database: # noqa: PLR0904
)
@staticmethod
- def create_user(email: str) -> tuple[int, str]:
+ def create_user(email: str, status: str = "pending") -> tuple[int, str]:
"""Create a new user and return (user_id, token).
+ Args:
+ email: User email address
+ status: Initial status (pending, active, or disabled)
+
Raises:
ValueError: If user ID cannot be retrieved after insert or if user
- not found.
+ not found, or if status is invalid.
"""
+ if status not in {"pending", "active", "disabled"}:
+ msg = f"Invalid status: {status}"
+ raise ValueError(msg)
+
# Generate a secure token for RSS feed access
token = secrets.token_urlsafe(32)
with Database.get_connection() as conn:
@@ -590,14 +598,19 @@ class Database: # noqa: PLR0904
try:
cursor.execute(
"INSERT INTO users (email, token, status) VALUES (?, ?, ?)",
- (email, token, "pending"),
+ (email, token, status),
)
conn.commit()
user_id = cursor.lastrowid
if user_id is None:
msg = "Failed to get user ID after insert"
raise ValueError(msg)
- logger.info("Created user %s with email %s", user_id, email)
+ logger.info(
+ "Created user %s with email %s (status: %s)",
+ user_id,
+ email,
+ status,
+ )
except sqlite3.IntegrityError:
# User already exists
cursor.execute(