Initial project commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import (
|
||||
Boolean, DateTime, Float, ForeignKey, Integer, Numeric,
|
||||
String, Text, func,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class ShootingRequest(Base):
|
||||
__tablename__ = "shooting_requests"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
creator_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
title: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
city: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
|
||||
description: Mapped[str | None] = mapped_column(Text)
|
||||
style: Mapped[str | None] = mapped_column(String(100))
|
||||
shoot_date: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
||||
is_free: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
budget_min: Mapped[float | None] = mapped_column(Numeric(10, 2))
|
||||
budget_max: Mapped[float | None] = mapped_column(Numeric(10, 2))
|
||||
role_needed: Mapped[str] = mapped_column(String(20), default="photographer")
|
||||
max_applicants: Mapped[int] = mapped_column(Integer, default=1)
|
||||
contact_info: Mapped[str | None] = mapped_column(String(200))
|
||||
spot_id: Mapped[int | None] = mapped_column(Integer, ForeignKey("spots.id"), nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(20), default="open", index=True)
|
||||
audit_status: Mapped[str] = mapped_column(String(20), default="pending")
|
||||
reject_reason: Mapped[str | None] = mapped_column(String(500))
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
creator = relationship("User", lazy="selectin")
|
||||
spot = relationship("Spot", lazy="selectin")
|
||||
applications = relationship("ShootingApplication", back_populates="request", lazy="selectin")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<ShootingRequest {self.id} {self.title}>"
|
||||
|
||||
|
||||
class ShootingApplication(Base):
|
||||
__tablename__ = "shooting_applications"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
request_id: Mapped[int] = mapped_column(Integer, ForeignKey("shooting_requests.id"), nullable=False, index=True)
|
||||
applicant_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
message: Mapped[str | None] = mapped_column(Text)
|
||||
status: Mapped[str] = mapped_column(String(20), default="pending")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
request = relationship("ShootingRequest", back_populates="applications")
|
||||
applicant = relationship("User", lazy="selectin")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<ShootingApplication {self.id} req={self.request_id}>"
|
||||
Reference in New Issue
Block a user