|
|
@ -1,4 +1,4 @@ |
|
|
|
from django.shortcuts import render, reverse |
|
|
|
from django.shortcuts import render, reverse, get_object_or_404 |
|
|
|
from posts.models import Post |
|
|
|
from posts.models import Post |
|
|
|
from django.http import Http404, HttpResponseRedirect |
|
|
|
from django.http import Http404, HttpResponseRedirect |
|
|
|
from .models import Comment, CommentAuthor |
|
|
|
from .models import Comment, CommentAuthor |
|
|
@ -12,11 +12,10 @@ from typing import Union |
|
|
|
|
|
|
|
|
|
|
|
def leave_comment(request, post_id): |
|
|
|
def leave_comment(request, post_id): |
|
|
|
parent: Union[Comment, None] |
|
|
|
parent: Union[Comment, None] |
|
|
|
|
|
|
|
post: Post |
|
|
|
|
|
|
|
author: Union[CommentAuthor, None] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
post = get_object_or_404(Post, pk=post_id) |
|
|
|
post = Post.objects.get(id=post_id) |
|
|
|
|
|
|
|
except ObjectDoesNotExist: |
|
|
|
|
|
|
|
raise Http404("Пост не найден") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# сделать проверку более вменяемой |
|
|
|
# сделать проверку более вменяемой |
|
|
|
parent_id = request.POST["reply_to"] |
|
|
|
parent_id = request.POST["reply_to"] |
|
|
|