chore(quality): apply ruff autofixes and formatting (8 fixes, 18 files reformatted)
This commit is contained in:
+30
-14
@@ -1,21 +1,37 @@
|
||||
"""User model."""
|
||||
from sqlalchemy import Column, Integer, String, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import String, DateTime, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""User model."""
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
email = Column(String(255), unique=True, index=True, nullable=False)
|
||||
username = Column(String(100), unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String(255), nullable=False)
|
||||
full_name = Column(String(255))
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
is_active = Column(Integer, default=1)
|
||||
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)
|
||||
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
role: Mapped[str] = mapped_column(String(50), default="member")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
|
||||
workspaces = relationship("Workspace", back_populates="owner")
|
||||
comments = relationship("Comment", back_populates="author")
|
||||
# Relationships
|
||||
owned_workspaces = relationship("Workspace", back_populates="owner")
|
||||
workspace_memberships = relationship("WorkspaceMember", back_populates="user")
|
||||
created_records = relationship(
|
||||
"Record", back_populates="created_by_user", foreign_keys="Record.created_by"
|
||||
)
|
||||
updated_records = relationship(
|
||||
"Record", back_populates="updated_by_user", foreign_keys="Record.updated_by"
|
||||
)
|
||||
comments = relationship("Comment", back_populates="user")
|
||||
views = relationship("View", back_populates="created_by_user")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<User(id={self.id}, email={self.email}, role={self.role})>"
|
||||
|
||||
Reference in New Issue
Block a user