На заливку

This commit is contained in:
iriska-gri committed 2023-10-04 10:35:01 +03:00
1 parent a6feb8449f
commit 94bbdeca40
7 files changed
+81 -19

No files matched your search

+9 -5
View File
@@ -34,17 +34,21 @@ class NewsAPIView(ListAPIView):
a=model_to_dict(x)
a['link']= str(x.link.url)
a['show'] = False
a['showComment'] = False
a['author'] = model_to_dict(DictEmployee.objects.using('user_directory').get(login=x.author.username))
a['scores'] = [{"score":y.score, "user":y.author.id} for y in x.get_news.all()]
a['comment'] = [{"author":k.author.id,
"cdate":k.cdate,
"text":k.text
} for k in x.get_comment_news.all()
]
result.append(a)
return Response(result)
# "author":model_to_dict(DictEmployee.objects.values("fio").using('user_directory').get(login=k.author.username))
def post(self, request):
print(request.data, '-----------------------')
upd, created = ScoreNews.objects.get_or_create(news_id=request.data['news'], author=self.request.user)
if created or (upd.score != request.data['scores']):