diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 8ba19f316..e48aee889 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -49,11 +49,13 @@ - - @@ -161,9 +163,9 @@ {% if i.note %} + data-toggle="popover" + data-placement="right" data-html="true" data-trigger="focus" + data-content="{{ i.note }}">
@@ -265,7 +267,7 @@

- +
{% trans 'Comments' %}
{% for c in comments %} @@ -279,19 +281,21 @@
{% endfor %} -
+ {% if request.user.is_authenticated %} +
-
- {% csrf_token %} -
+ + {% csrf_token %} +
-
- +
+ +
-
- -
+ +
+ {% endif %} {% if recipe.storage %} {% include 'include/recipe_open_modal.html' %} @@ -340,7 +344,9 @@ }); function roundDecimals(num) { - return +(Math.round(num + "e+{{ request.user.userpreference.ingredient_decimals }}") + "e-{{ request.user.userpreference.ingredient_decimals }}"); + let decimals = {% if request.user.userpreference.ingredient_decimals %} + {{ request.user.userpreference.ingredient_decimals }} {% else %} 2 {% endif %} + return +(Math.round(num + `e+${decimals}`) + `e-${decimals}`); } function reloadIngredients() { diff --git a/cookbook/views/views.py b/cookbook/views/views.py index 9f29fdf86..c510d78f6 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -77,10 +77,14 @@ def recipe_view(request, pk, share=None): messages.add_message(request, messages.ERROR, _('You do not have the required permissions to view this page!')) return HttpResponseRedirect(reverse('index')) - ingredients = RecipeIngredient.objects.filter(recipe=recipe) + ingredients = RecipeIngredient.objects.filter(recipe=recipe).all() comments = Comment.objects.filter(recipe=recipe) if request.method == "POST": + if not request.user.is_authenticated: + messages.add_message(request, messages.ERROR, _('You do not have the required permissions to perform this action!')) + return HttpResponseRedirect(reverse('view_recipe', kwargs={'pk': recipe.pk, 'share': share})) + comment_form = CommentForm(request.POST, prefix='comment') if comment_form.is_valid(): comment = Comment()