61 lines
1.3 KiB
Python
61 lines
1.3 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, field_validator
|
|
|
|
from app.models.fit import FitLabel
|
|
from app.schemas.attachment_point import AttachmentPointRead
|
|
|
|
|
|
class FitNoteCreate(BaseModel):
|
|
body: str
|
|
|
|
@field_validator("body")
|
|
@classmethod
|
|
def validate_body(cls, v: str) -> str:
|
|
if not v.strip():
|
|
raise ValueError("body must not be blank")
|
|
return v.strip()
|
|
|
|
|
|
class FitNoteRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
fit_id: int
|
|
user_id: int | None
|
|
username: str
|
|
body: str
|
|
created_at: datetime
|
|
|
|
|
|
class FitCreate(BaseModel):
|
|
"""Manually-declared fit; recorded as Exact regardless of the match algorithm."""
|
|
|
|
attachment_point_a_id: int
|
|
attachment_point_b_id: int
|
|
|
|
|
|
class FitUpdate(BaseModel):
|
|
label: FitLabel
|
|
|
|
|
|
class FitRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
augmented_part_a_id: int
|
|
augmented_part_b_id: int
|
|
attachment_point_a_id: int
|
|
attachment_point_b_id: int
|
|
attachment_point_a: AttachmentPointRead
|
|
attachment_point_b: AttachmentPointRead
|
|
label: FitLabel
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
notes: list[FitNoteRead] = []
|
|
|
|
|
|
class FitRecomputeResult(BaseModel):
|
|
created: int
|
|
removed: int
|