mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-08 23:58:15 -05:00
fixed unauthenticated recipe viewing
This commit is contained in:
@@ -49,11 +49,13 @@
|
||||
<a class="btn btn-light" onclick="window.print()" data-toggle="tooltip"
|
||||
data-placement="top" title="{% trans 'Print' %}"><i
|
||||
class="fas fa-print"></i></a>
|
||||
<a class="btn btn-primary" href="{% url 'view_export' %}?r={{ recipe.pk }}" target="_blank" rel="noopener noreferrer"
|
||||
<a class="btn btn-primary" href="{% url 'view_export' %}?r={{ recipe.pk }}" target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
data-toggle="tooltip"
|
||||
data-placement="top" title="{% trans 'Export recipe' %}"><i
|
||||
class="fas fa-file-export"></i></a>
|
||||
<a class="btn btn-primary" href="{% url 'new_share_link' recipe.pk %}" target="_blank" rel="noopener noreferrer"
|
||||
<a class="btn btn-primary" href="{% url 'new_share_link' recipe.pk %}" target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
data-toggle="tooltip"
|
||||
data-placement="top" title="{% trans 'Create share link' %}"><i class="fas fa-share-alt"></i></a>
|
||||
</div>
|
||||
@@ -279,6 +281,7 @@
|
||||
<br/>
|
||||
{% endfor %}
|
||||
|
||||
{% if request.user.is_authenticated %}
|
||||
<div class="d-print-none">
|
||||
|
||||
<form method="POST" class="post-form">
|
||||
@@ -292,6 +295,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% 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() {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user