Public Access
feat: never-suggest CRUD endpoints (ingredient and recipe blocklist)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
|
||||
|
||||
class NeverSuggestCreate(BaseModel):
|
||||
family_profile_id: UUID
|
||||
ingredient_id: Optional[UUID] = None
|
||||
recipe_id: Optional[UUID] = None
|
||||
reason: Optional[str] = Field(default=None, max_length=50)
|
||||
notes: Optional[str] = None
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _exactly_one_target(self) -> "NeverSuggestCreate":
|
||||
present = sum(x is not None for x in (self.ingredient_id, self.recipe_id))
|
||||
if present != 1:
|
||||
raise ValueError("exactly one of ingredient_id or recipe_id must be set")
|
||||
return self
|
||||
|
||||
|
||||
class NeverSuggestRead(BaseModel):
|
||||
id: UUID
|
||||
family_profile_id: UUID
|
||||
ingredient_id: Optional[UUID] = None
|
||||
recipe_id: Optional[UUID] = None
|
||||
reason: Optional[str] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
Reference in New Issue
Block a user