mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-26 09:43:19 -05:00
add to schema
This commit is contained in:
@@ -130,7 +130,19 @@ class CreateIngredientUnit(UnitFoodBase):
|
|||||||
abbreviation: str = ""
|
abbreviation: str = ""
|
||||||
plural_abbreviation: str | None = ""
|
plural_abbreviation: str | None = ""
|
||||||
use_abbreviation: bool = False
|
use_abbreviation: bool = False
|
||||||
|
|
||||||
aliases: list[CreateIngredientUnitAlias] = []
|
aliases: list[CreateIngredientUnitAlias] = []
|
||||||
|
standard_quantity: float | None = None
|
||||||
|
standard_unit: str | None = None
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def validate_standardization_fields(self):
|
||||||
|
# If one is set, the other must be set.
|
||||||
|
# If quantity is <= 0, it's considered not set.
|
||||||
|
if not self.standard_unit:
|
||||||
|
self.standard_quantity = self.standard_unit = None
|
||||||
|
elif not ((self.standard_quantity or 0) > 0):
|
||||||
|
self.standard_quantity = self.standard_unit = None
|
||||||
|
|
||||||
|
|
||||||
class SaveIngredientUnit(CreateIngredientUnit):
|
class SaveIngredientUnit(CreateIngredientUnit):
|
||||||
|
|||||||
Reference in New Issue
Block a user