basic shopping list fix
This commit is contained in:
@ -189,6 +189,9 @@ class Recipe(models.Model):
|
|||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class Comment(models.Model):
|
class Comment(models.Model):
|
||||||
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
|
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
<!--// @formatter:off-->
|
<!--// @formatter:off-->
|
||||||
<textarea id="id_list" class="form-control" rows="{{ ingredients|length|add:1 }}">{% for i in ingredients %}{% if markdown_format %}- [ ] {% endif %}{{ i.amount.normalize }} {{ i.unit }} {{ i.ingredient.name }} {% endfor %}</textarea>
|
<textarea id="id_list" class="form-control" rows="{{ ingredients|length|add:1 }}">{% for i in ingredients %}{% if markdown_format %}- [ ] {% endif %}{{ i.amount.normalize }} {{ i.unit }} {{ i.food.name }} {% endfor %}</textarea>
|
||||||
<!--// @formatter:on-->
|
<!--// @formatter:on-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -189,10 +189,11 @@ def shopping_list(request):
|
|||||||
ingredients = []
|
ingredients = []
|
||||||
|
|
||||||
for r in recipes:
|
for r in recipes:
|
||||||
for ri in RecipeIngredient.objects.filter(recipe=r).exclude(unit__name__contains='Special:').all():
|
for s in r.steps.all():
|
||||||
|
for ri in s.ingredients.exclude(unit__name__contains='Special:').all():
|
||||||
index = None
|
index = None
|
||||||
for x, ig in enumerate(ingredients):
|
for x, ig in enumerate(ingredients):
|
||||||
if ri.ingredient == ig.ingredient and ri.unit == ig.unit:
|
if ri.food == ig.food and ri.unit == ig.unit:
|
||||||
index = x
|
index = x
|
||||||
|
|
||||||
if index:
|
if index:
|
||||||
|
Reference in New Issue
Block a user