mirror of
https://github.com/pocketpaw/pocketpaw.git
synced 2026-05-20 08:49:49 +00:00
- Auto-fix 155 errors (import sorting, annotations, deprecated imports) - Format 87 files with ruff format for line length compliance - Fix 15 F401 unused imports (add __all__ for re-exports, remove truly unused) - Fix 7 F841 unused variables (prefix with _) - Fix 2 F821 undefined names (add missing imports) - Fix 3 E402 module-level imports not at top - Fix 2 UP042 str+Enum → StrEnum - Fix 1 E712 == False comparison - Fix remaining 51 E501 line-too-long in string literals and expressions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""User and OAuth account models (fastapi-users + Beanie)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from beanie import Document
|
|
from fastapi_users_db_beanie import BaseOAuthAccount, BeanieBaseUser
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class OAuthAccount(BaseOAuthAccount):
|
|
"""OAuth account linked to a User (Google, GitHub, etc.)."""
|
|
|
|
pass
|
|
|
|
|
|
class WorkspaceMembership(BaseModel):
|
|
workspace: str # Workspace ID
|
|
role: str = "member" # owner | admin | member | viewer
|
|
joined_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
|
|
|
|
class User(BeanieBaseUser, Document): # type: ignore[misc]
|
|
"""Enterprise user with OAuth support."""
|
|
|
|
full_name: str = ""
|
|
avatar: str = ""
|
|
active_workspace: str | None = None # Current workspace ID
|
|
workspaces: list[WorkspaceMembership] = Field(default_factory=list)
|
|
status: str = Field(default="offline", pattern="^(online|offline|away|dnd)$")
|
|
last_seen: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
oauth_accounts: list[OAuthAccount] = Field(default_factory=list)
|
|
|
|
class Settings:
|
|
name = "users"
|
|
email_collation = None
|