1
0
mirror of https://github.com/TandoorRecipes/recipes.git synced 2026-01-11 00:58:32 -05:00

fixed unauthenticated recipe viewing

This commit is contained in:
vabene1111
2020-06-16 11:49:02 +02:00
parent dee7249347
commit 62c049a6de
2 changed files with 27 additions and 17 deletions

View File

@@ -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()