Левое меню

This commit is contained in:
iriska-gri committed 2023-10-05 13:41:30 +03:00
1 parent d8a9d31938
commit c5dab0b2a6
6 files changed
+59 -13

No files matched your search

+9 -2
View File
@@ -39,7 +39,8 @@ class NewsAPIView(ListAPIView):
a['scores'] = [{"score":y.score, "user":y.author.username} for y in x.get_news.all()]
a['comment'] = [{"author":model_to_dict(DictEmployee.objects.using('user_directory').get(login=k.author.username)),
"cdate":k.cdate,
"text":k.text
"text":k.text,
"id": k.pk
} for k in x.get_comment_news.all()
]
@@ -62,7 +63,13 @@ class NewsAPIView(ListAPIView):
if 'text' in request.data:
CommentNews.objects.create(news_id=request.data['news'], author=self.request.user, text=request.data['text'])
back = {'news': request.data['news'], 'comment': ({"text":y.text, "cdate":y.cdate,
back = {'news': request.data['news'], 'comment': ({"text":y.text, "cdate":y.cdate, "id": y.pk,
"author":model_to_dict(DictEmployee.objects.using('user_directory').get(login=y.author.username))
} for y in CommentNews.objects.filter(news_id=request.data['news']))}
if 'delid' in request.data:
CommentNews.objects.filter(pk=request.data['delid']).delete()
back = {'news': request.data['news'], 'comment': ({"text":y.text, "cdate":y.cdate, "id": y.pk,
"author":model_to_dict(DictEmployee.objects.using('user_directory').get(login=y.author.username))
} for y in CommentNews.objects.filter(news_id=request.data['news']))}