fix duplicate shopping entries when using old list
This commit is contained in:
parent
47823132f0
commit
4a48019885
@ -692,7 +692,8 @@ class ShoppingListRecipeSerializer(serializers.ModelSerializer):
|
|||||||
) + f' ({value:.2g})'
|
) + f' ({value:.2g})'
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
if 'servings' in validated_data:
|
# TODO remove once old shopping list
|
||||||
|
if 'servings' in validated_data and self.context.get('view', None).__class__.__name__ != 'ShoppingListViewSet':
|
||||||
list_from_recipe(
|
list_from_recipe(
|
||||||
list_recipe=instance,
|
list_recipe=instance,
|
||||||
servings=validated_data['servings'],
|
servings=validated_data['servings'],
|
||||||
|
@ -121,11 +121,3 @@ def auto_add_shopping(sender, instance=None, created=False, weak=False, **kwargs
|
|||||||
'servings': instance.servings
|
'servings': instance.servings
|
||||||
}
|
}
|
||||||
list_recipe = list_from_recipe(**kwargs)
|
list_recipe = list_from_recipe(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
# user = self.context['request'].user
|
|
||||||
# if user.userpreference.shopping_add_onhand:
|
|
||||||
# if checked := validated_data.get('checked', None):
|
|
||||||
# instance.food.onhand_users.add(*user.userpreference.shopping_share.all(), user)
|
|
||||||
# elif checked == False:
|
|
||||||
# instance.food.onhand_users.remove(*user.userpreference.shopping_share.all(), user)
|
|
||||||
|
@ -834,7 +834,7 @@
|
|||||||
this.$http.get('{% url 'api:recipe-detail' 123456 %}'.replace('123456', recipe.id)).then((response) => {
|
this.$http.get('{% url 'api:recipe-detail' 123456 %}'.replace('123456', recipe.id)).then((response) => {
|
||||||
for (let s of response.data.steps) {
|
for (let s of response.data.steps) {
|
||||||
for (let i of s.ingredients) {
|
for (let i of s.ingredients) {
|
||||||
if (!i.is_header && i.food !== null && i.food.food_onhand === false) {
|
if (!i.is_header && i.food !== null && !i.food.ignore_food) {
|
||||||
this.shopping_list.entries.push({
|
this.shopping_list.entries.push({
|
||||||
'list_recipe': slr.id,
|
'list_recipe': slr.id,
|
||||||
'food': i.food,
|
'food': i.food,
|
||||||
|
@ -1096,6 +1096,7 @@ export default {
|
|||||||
if (!autosync) {
|
if (!autosync) {
|
||||||
if (results.data?.length) {
|
if (results.data?.length) {
|
||||||
this.items = results.data
|
this.items = results.data
|
||||||
|
console.log(this.items)
|
||||||
} else {
|
} else {
|
||||||
console.log("no data returned")
|
console.log("no data returned")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user