chore(quality): apply ruff autofixes and formatting (8 fixes, 18 files reformatted)
This commit is contained in:
+24
-11
@@ -1,19 +1,32 @@
|
||||
"""View model."""
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import String, DateTime, Boolean, ForeignKey, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy import JSON
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class View(Base):
|
||||
"""View model."""
|
||||
__tablename__ = "views"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(255), nullable=False)
|
||||
view_type = Column(String(50), default="grid") # grid, gallery, form
|
||||
table_id = Column(Integer, ForeignKey("tables.id"), nullable=False)
|
||||
config = Column(Text) # JSON config for view settings
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
table_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("tables.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
type: Mapped[str] = mapped_column(String(50), default="grid") # grid, gallery, form
|
||||
config: Mapped[Optional[dict]] = mapped_column(
|
||||
JSON, nullable=True
|
||||
) # filter, sort, columns
|
||||
is_default: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
created_by: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=func.now())
|
||||
|
||||
# Relationships
|
||||
table = relationship("Table", back_populates="views")
|
||||
created_by_user = relationship("User", back_populates="views")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<View(id={self.id}, name={self.name}, type={self.type})>"
|
||||
|
||||
Reference in New Issue
Block a user