init: new structure + fix lint errors
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from cpv3.db.base import Base, BaseModelMixin
|
||||
|
||||
|
||||
def utcnow() -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
|
||||
class User(Base, BaseModelMixin):
|
||||
__tablename__ = "users"
|
||||
|
||||
username: Mapped[str] = mapped_column(String(150), unique=True, index=True)
|
||||
email: Mapped[str] = mapped_column(String(254), default="")
|
||||
|
||||
password_hash: Mapped[str] = mapped_column(String(255))
|
||||
|
||||
first_name: Mapped[str] = mapped_column(String(150), default="")
|
||||
last_name: Mapped[str] = mapped_column(String(150), default="")
|
||||
|
||||
phone_number: Mapped[str | None] = mapped_column(String(15), unique=True, nullable=True)
|
||||
avatar: Mapped[str | None] = mapped_column(String(2048), nullable=True)
|
||||
|
||||
email_verified: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
phone_verified: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
|
||||
is_staff: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
is_superuser: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
|
||||
date_joined: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
last_login: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
Reference in New Issue
Block a user