The demo account — one shared user that whitelisted emails entered from the login page, reset on a schedule — goes end to end (owner decision, E34): demo.py and the reset job, users.is_demo and demo_whitelist (migration 0098 deletes the demo user, its audit rows, the reset job's override and notices, then drops the column and table; the downgrade restores the empty schema), the /auth/demo entry, the admin whitelist and reset, the Demo tab, the banner, the login page's "Try the demo", and every is_demo branch in routes, userscope, scheduler and the UI. require_human only ever refused the demo account, so its 87 uses become current_user (owner-approved); require_write_scope keeps its own check. The login page's "or" divider now shows only beside the Google button: without the demo entry under it, an instance without Google would have said "or" to nothing. A contract test (removedFeatures) fails on the word anywhere in the backend, frontend, e2e or scripts — seen red on a planted hit. Size ceilings tightened for the modules that shrank; admin.py is back under the limit.
23 lines
875 B
Python
23 lines
875 B
Python
"""Shared "who is an active, non-suspended account" predicate.
|
|
|
|
Used wherever a user must be filtered out of a recipient list or rejected as a target: the download
|
|
share-by-email and recipient-picker endpoints. Kept in one place so the two forms (SQL clauses for a
|
|
query, Python check for a loaded row) can't drift apart, and so a route module doesn't have to import
|
|
another route module just to reuse the rule.
|
|
"""
|
|
|
|
from app.models import User
|
|
|
|
|
|
def messageable_clauses() -> list:
|
|
"""SQL clauses for "an active, non-suspended account" — splat into a recipient query."""
|
|
return [
|
|
User.is_active.is_(True),
|
|
User.is_suspended.is_(False),
|
|
]
|
|
|
|
|
|
def is_messageable_user(u: User | None) -> bool:
|
|
"""Python mirror of `messageable_clauses()` for an already-loaded row (a share recipient)."""
|
|
return bool(u and u.is_active and not u.is_suspended)
|