Initialize Sneaky Klaus project with: - uv package management and pyproject.toml - Flask application structure (app.py, config.py) - SQLAlchemy models for Admin and Exchange - Alembic database migrations - Pre-commit hooks configuration - Development tooling (pytest, ruff, mypy) Initial structure follows design documents in docs/: - src/app.py: Application factory with Flask extensions - src/config.py: Environment-based configuration - src/models/: Admin and Exchange models - migrations/: Alembic migration setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Admin model for Sneaky Klaus.
|
|
|
|
The Admin model represents the single administrator account
|
|
for the entire installation.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from src.app import db
|
|
|
|
|
|
class Admin(db.Model): # type: ignore[name-defined]
|
|
"""Administrator user model.
|
|
|
|
Represents the single admin account for the entire Sneaky Klaus installation.
|
|
Only one admin should exist per deployment.
|
|
|
|
Attributes:
|
|
id: Auto-increment primary key.
|
|
email: Admin email address (unique, indexed).
|
|
password_hash: bcrypt password hash.
|
|
created_at: Account creation timestamp.
|
|
updated_at: Last update timestamp.
|
|
"""
|
|
|
|
__tablename__ = "admin"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
email: Mapped[str] = mapped_column(
|
|
String(255), unique=True, nullable=False, index=True
|
|
)
|
|
password_hash: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime, nullable=False, default=datetime.utcnow
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime,
|
|
nullable=False,
|
|
default=datetime.utcnow,
|
|
onupdate=datetime.utcnow,
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
"""String representation of Admin instance."""
|
|
return f"<Admin {self.email}>"
|