diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 6507e5191..302e78fa8 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -8,6 +8,20 @@ {% block content %}

{{ recipe.name }}

+
+
+
+
{% trans 'Ingredients' %}
+ + + {% for i in ingredients %} + {{ i.amount }} {{ i.unit }} {{ i.ingredient.name }}
+ {% endfor %} + +
+
+
+
{{ recipe.instructions | markdown | safe }} diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index bdad01803..73912defa 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -27,7 +27,7 @@ def internal_recipe_update(request, pk): if request.method == "POST": form = InternalRecipeForm(request.POST) if form.is_valid(): - recipe = Recipe() + recipe = recipe_instance recipe.name = form.cleaned_data['name'] recipe.instructions = form.cleaned_data['instructions'] @@ -36,7 +36,7 @@ def internal_recipe_update(request, pk): recipe.keywords.set(form.cleaned_data['keywords']) messages.add_message(request, messages.SUCCESS, _('Recipe saved!')) - return redirect('index') + return HttpResponseRedirect(reverse('edit_internal_recipe', args=[pk])) else: messages.add_message(request, messages.ERROR, _('There was an error importing this recipe!')) else: diff --git a/cookbook/views/views.py b/cookbook/views/views.py index c96db9209..96085b199 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -22,7 +22,9 @@ def index(request): @login_required def recipe_view(request, pk): recipe = get_object_or_404(Recipe, pk=pk) - return render(request, 'recipe_view.html', {'recipe': recipe}) + ingredients = RecipeIngredients.objects.filter(recipe=recipe) + + return render(request, 'recipe_view.html', {'recipe': recipe, 'ingredients': ingredients}) def test(request):