Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopping List always duplicates the first item #121

Closed
rrash283 opened this issue Jun 22, 2020 · 1 comment
Closed

Shopping List always duplicates the first item #121

rrash283 opened this issue Jun 22, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@rrash283
Copy link

Version

Please provide your current version (can be found on the system page since v0.8.4)
Version:

Bug description

The first ingredient added to the ingredient list will have an index of 0. If that same ingredient is used again in it assigns index = 0
if index: when index = 0 returns False so the ingredient is added to the list again.
The code needs to be changed to something like if index is not None:

The code below is from the shopping list view.

for r in recipes:
        for ri in RecipeIngredient.objects.filter(recipe=r).exclude(unit__name__contains='Special:').all():
            index = None
            for x, ig in enumerate(ingredients):
                if ri.ingredient == ig.ingredient and ri.unit == ig.unit:
                    index = x

            if index:
                ingredients[index].amount = ingredients[index].amount + ri.amount
            else:
                ingredients.append(ri)
@vabene1111
Copy link
Collaborator

thanks for the detailed report! the shopping list really need a rework, this is another reason why #114

@vabene1111 vabene1111 added the bug Something isn't working label Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants