fix duplicate shopping entries when using old list

This commit is contained in:
Chris Scoggins 2022-01-26 14:47:33 -06:00
parent 47823132f0
commit 4a48019885
No known key found for this signature in database
GPG Key ID: 41617A4206CCBAC6
4 changed files with 4 additions and 10 deletions

View File

@ -692,7 +692,8 @@ class ShoppingListRecipeSerializer(serializers.ModelSerializer):
) + f' ({value:.2g})'
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_recipe=instance,
servings=validated_data['servings'],

View File

@ -121,11 +121,3 @@ def auto_add_shopping(sender, instance=None, created=False, weak=False, **kwargs
'servings': instance.servings
}
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)

View File

@ -834,7 +834,7 @@
this.$http.get('{% url 'api:recipe-detail' 123456 %}'.replace('123456', recipe.id)).then((response) => {
for (let s of response.data.steps) {
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({
'list_recipe': slr.id,
'food': i.food,

View File

@ -1096,6 +1096,7 @@ export default {
if (!autosync) {
if (results.data?.length) {
this.items = results.data
console.log(this.items)
} else {
console.log("no data returned")
}