64 lines
1.4 KiB
Python
64 lines
1.4 KiB
Python
|
|
import uuid
|
||
|
|
|
||
|
|
from pydantic import BaseModel
|
||
|
|
|
||
|
|
from app.models.plant import CompatibilityRating, NutrientDemand, WaterDemand
|
||
|
|
|
||
|
|
|
||
|
|
class PlantFamilyRead(BaseModel):
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
id: uuid.UUID
|
||
|
|
name: str
|
||
|
|
latin_name: str
|
||
|
|
|
||
|
|
|
||
|
|
class PlantBase(BaseModel):
|
||
|
|
name: str
|
||
|
|
latin_name: str | None = None
|
||
|
|
family_id: uuid.UUID
|
||
|
|
nutrient_demand: NutrientDemand
|
||
|
|
water_demand: WaterDemand
|
||
|
|
spacing_cm: int
|
||
|
|
sowing_start_month: int
|
||
|
|
sowing_end_month: int
|
||
|
|
rest_years: int = 0
|
||
|
|
notes: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class PlantCreate(PlantBase):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
class PlantUpdate(BaseModel):
|
||
|
|
name: str | None = None
|
||
|
|
latin_name: str | None = None
|
||
|
|
family_id: uuid.UUID | None = None
|
||
|
|
nutrient_demand: NutrientDemand | None = None
|
||
|
|
water_demand: WaterDemand | None = None
|
||
|
|
spacing_cm: int | None = None
|
||
|
|
sowing_start_month: int | None = None
|
||
|
|
sowing_end_month: int | None = None
|
||
|
|
rest_years: int | None = None
|
||
|
|
notes: str | None = None
|
||
|
|
is_active: bool | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class PlantRead(PlantBase):
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
id: uuid.UUID
|
||
|
|
tenant_id: uuid.UUID | None
|
||
|
|
is_active: bool
|
||
|
|
family: PlantFamilyRead
|
||
|
|
|
||
|
|
|
||
|
|
class PlantCompatibilityRead(BaseModel):
|
||
|
|
model_config = {"from_attributes": True}
|
||
|
|
|
||
|
|
id: uuid.UUID
|
||
|
|
plant_id_a: uuid.UUID
|
||
|
|
plant_id_b: uuid.UUID
|
||
|
|
rating: CompatibilityRating
|
||
|
|
reason: str | None
|