mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
support empty meal-plans
This commit is contained in:
parent
e662e43288
commit
fba3ed68fa
@ -33,7 +33,7 @@
|
|||||||
:key="generateKey(meal.slug, index)"
|
:key="generateKey(meal.slug, index)"
|
||||||
>
|
>
|
||||||
<v-img
|
<v-img
|
||||||
class="rounded-lg"
|
class="rounded-lg info"
|
||||||
:src="getImage(meal.image)"
|
:src="getImage(meal.image)"
|
||||||
height="80"
|
height="80"
|
||||||
width="80"
|
width="80"
|
||||||
@ -105,7 +105,6 @@ export default {
|
|||||||
editPlan(id) {
|
editPlan(id) {
|
||||||
this.plannedMeals.forEach((element) => {
|
this.plannedMeals.forEach((element) => {
|
||||||
if (element.uid === id) {
|
if (element.uid === id) {
|
||||||
console.log(element);
|
|
||||||
this.editMealPlan = element;
|
this.editMealPlan = element;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -107,7 +107,7 @@ export default {
|
|||||||
this.meals = [];
|
this.meals = [];
|
||||||
for (let i = 0; i < this.dateDif; i++) {
|
for (let i = 0; i < this.dateDif; i++) {
|
||||||
this.meals.push({
|
this.meals.push({
|
||||||
slug: "",
|
slug: "empty",
|
||||||
date: this.getDate(i),
|
date: this.getDate(i),
|
||||||
dateText: this.getDayText(i),
|
dateText: this.getDayText(i),
|
||||||
});
|
});
|
||||||
|
@ -17,15 +17,16 @@ async def get_all_meals():
|
|||||||
@router.post("/api/meal-plan/create/", tags=["Meal Plan"])
|
@router.post("/api/meal-plan/create/", tags=["Meal Plan"])
|
||||||
async def set_meal_plan(data: MealPlan):
|
async def set_meal_plan(data: MealPlan):
|
||||||
""" Creates Mealplan from Frontend Data"""
|
""" Creates Mealplan from Frontend Data"""
|
||||||
|
data.process_meals()
|
||||||
|
data.save_to_db()
|
||||||
|
|
||||||
|
# try:
|
||||||
|
|
||||||
try:
|
# except:
|
||||||
data.process_meals()
|
# raise HTTPException(
|
||||||
data.save_to_db()
|
# status_code=404,
|
||||||
except:
|
# detail=SnackResponse.error("Unable to Create Mealplan See Log"),
|
||||||
raise HTTPException(
|
# )
|
||||||
status_code=404,
|
|
||||||
detail=SnackResponse.error("Unable to Create Mealplan See Log"),
|
|
||||||
)
|
|
||||||
|
|
||||||
return SnackResponse.success("Mealplan Created")
|
return SnackResponse.success("Mealplan Created")
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ WEEKDAYS = [
|
|||||||
|
|
||||||
|
|
||||||
class Meal(BaseModel):
|
class Meal(BaseModel):
|
||||||
slug: str
|
slug: Optional[str]
|
||||||
name: Optional[str]
|
name: Optional[str]
|
||||||
date: Optional[date]
|
date: date
|
||||||
dateText: str
|
dateText: str
|
||||||
image: Optional[str]
|
image: Optional[str]
|
||||||
description: Optional[str]
|
description: Optional[str]
|
||||||
@ -57,16 +57,23 @@ class MealPlan(BaseModel):
|
|||||||
def process_meals(self):
|
def process_meals(self):
|
||||||
meals = []
|
meals = []
|
||||||
for x, meal in enumerate(self.meals):
|
for x, meal in enumerate(self.meals):
|
||||||
recipe = Recipe.get_by_slug(meal.slug)
|
|
||||||
|
|
||||||
meal_data = {
|
try:
|
||||||
"slug": recipe.slug,
|
recipe = Recipe.get_by_slug(meal.slug)
|
||||||
"name": recipe.name,
|
|
||||||
"date": self.startDate + timedelta(days=x),
|
meal_data = {
|
||||||
"dateText": meal.dateText,
|
"slug": recipe.slug,
|
||||||
"image": recipe.image,
|
"name": recipe.name,
|
||||||
"description": recipe.description,
|
"date": self.startDate + timedelta(days=x),
|
||||||
}
|
"dateText": meal.dateText,
|
||||||
|
"image": recipe.image,
|
||||||
|
"description": recipe.description,
|
||||||
|
}
|
||||||
|
except:
|
||||||
|
meal_data = {
|
||||||
|
"date": self.startDate + timedelta(days=x),
|
||||||
|
"dateText": meal.dateText,
|
||||||
|
}
|
||||||
|
|
||||||
meals.append(Meal(**meal_data))
|
meals.append(Meal(**meal_data))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user