fix add to shopping from MealPlan Modal
This commit is contained in:
@ -59,7 +59,7 @@ def list_from_recipe(list_recipe=None, recipe=None, mealplan=None, servings=None
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
servings = float(servings)
|
servings = float(servings)
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
servings = getattr(mealplan, 'servings', 1.0)
|
servings = getattr(mealplan, 'servings', 1.0)
|
||||||
|
|
||||||
servings_factor = servings / r.servings
|
servings_factor = servings / r.servings
|
||||||
@ -139,7 +139,7 @@ def list_from_recipe(list_recipe=None, recipe=None, mealplan=None, servings=None
|
|||||||
sle.save()
|
sle.save()
|
||||||
|
|
||||||
# add any missing Entrys
|
# add any missing Entrys
|
||||||
for i in [x for x in add_ingredients if not x.food.ignore_shopping]:
|
for i in [x for x in add_ingredients if x.food and not x.food.ignore_shopping]:
|
||||||
|
|
||||||
ShoppingListEntry.objects.create(
|
ShoppingListEntry.objects.create(
|
||||||
list_recipe=list_recipe,
|
list_recipe=list_recipe,
|
||||||
|
@ -628,7 +628,7 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer):
|
|||||||
validated_data['created_by'] = self.context['request'].user
|
validated_data['created_by'] = self.context['request'].user
|
||||||
mealplan = super().create(validated_data)
|
mealplan = super().create(validated_data)
|
||||||
if self.context['request'].data.get('addshopping', False):
|
if self.context['request'].data.get('addshopping', False):
|
||||||
list_from_recipe(mealplan=mealplan, space=validated_data['space'], created_by=validated_data['created_by'])
|
list_from_recipe(mealplan=mealplan, servings=validated_data['servings'], created_by=validated_data['created_by'], space=validated_data['space'])
|
||||||
return mealplan
|
return mealplan
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -125,6 +125,7 @@ export default {
|
|||||||
entry.date = moment(entry.date).format("YYYY-MM-DD")
|
entry.date = moment(entry.date).format("YYYY-MM-DD")
|
||||||
|
|
||||||
let apiClient = new ApiApiFactory()
|
let apiClient = new ApiApiFactory()
|
||||||
|
console.log("etnry", entry)
|
||||||
|
|
||||||
apiClient
|
apiClient
|
||||||
.createMealPlan(entry)
|
.createMealPlan(entry)
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- add alert at top if offline -->
|
|
||||||
<!-- get autosync time from preferences and put fetching checked items on timer -->
|
|
||||||
<!-- allow reordering or items -->
|
|
||||||
<div id="shopping_line_item">
|
<div id="shopping_line_item">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -231,10 +228,10 @@ export default {
|
|||||||
return [this.$t("DelayUntil"), "-", this.formatDate(item.delay_until)].join(" ")
|
return [this.$t("DelayUntil"), "-", this.formatDate(item.delay_until)].join(" ")
|
||||||
},
|
},
|
||||||
formatOneMealPlan: function (item) {
|
formatOneMealPlan: function (item) {
|
||||||
return item?.recipe_mealplan?.name
|
return item?.recipe_mealplan?.name ?? ""
|
||||||
},
|
},
|
||||||
formatOneRecipe: function (item) {
|
formatOneRecipe: function (item) {
|
||||||
return item?.recipe_mealplan?.recipe_name
|
return item?.recipe_mealplan?.recipe_name ?? ""
|
||||||
},
|
},
|
||||||
formatOneNote: function (item) {
|
formatOneNote: function (item) {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
Reference in New Issue
Block a user