mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
#183 added backend validation for mealplanning timespan
This commit is contained in:
parent
4611d6b791
commit
eda47b7bf4
1 changed files with 7 additions and 1 deletions
|
@ -2,7 +2,7 @@ from datetime import date, timedelta
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from db.database import db
|
from db.database import db
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, validator
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
from services.recipe_services import Recipe
|
from services.recipe_services import Recipe
|
||||||
|
@ -41,6 +41,12 @@ class MealPlan(BaseModel):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@validator('endDate')
|
||||||
|
def endDate_after_startDate(cls, v, values, **kwargs):
|
||||||
|
if 'startDate' in values and v < values['startDate']:
|
||||||
|
raise ValueError('EndDate should be greater than StartDate')
|
||||||
|
return v
|
||||||
|
|
||||||
def process_meals(self, session: Session):
|
def process_meals(self, session: Session):
|
||||||
meals = []
|
meals = []
|
||||||
for x, meal in enumerate(self.meals):
|
for x, meal in enumerate(self.meals):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue