mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-09-30 21:54:57 +02:00
39 lines
869 B
Python
39 lines
869 B
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
from shared.utils.datetime import utc_now
|
|
|
|
|
|
class ProjectBase(SQLModel):
|
|
name: str = Field(max_length=50)
|
|
|
|
|
|
class Project(ProjectBase, table=True):
|
|
__tablename__ = "projects"
|
|
|
|
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True, index=True)
|
|
slug: str = Field(max_length=100, unique=True, index=True)
|
|
is_active: bool = Field(default=True)
|
|
created_at: datetime = Field(default_factory=utc_now)
|
|
created_by: uuid.UUID = Field(foreign_key="users.id")
|
|
|
|
|
|
class ProjectCreate(ProjectBase):
|
|
pass
|
|
|
|
|
|
class ProjectRead(ProjectBase):
|
|
id: uuid.UUID
|
|
slug: str
|
|
is_active: bool
|
|
created_at: datetime
|
|
created_by: uuid.UUID
|
|
|
|
|
|
class ProjectSummary(BaseModel):
|
|
project: ProjectRead
|
|
stats: dict[str, int]
|