chore [P-01]: подтянул бэк
This commit is contained in:
commit
0db7bb3036
1 file changed
+7
-3
@@ -279,7 +279,7 @@ class TestingView(generics.ListCreateAPIView):
|
|||||||
completion_date=request.data["completion_date"],
|
completion_date=request.data["completion_date"],
|
||||||
test_passed=False,
|
test_passed=False,
|
||||||
)
|
)
|
||||||
if request.data.get("news") == "true":
|
if request.data.get("news"):
|
||||||
self.create_news(request, testing)
|
self.create_news(request, testing)
|
||||||
return Response(
|
return Response(
|
||||||
{"status": "success", "message": "Testing created successfully."},
|
{"status": "success", "message": "Testing created successfully."},
|
||||||
@@ -339,13 +339,17 @@ class TestingView(generics.ListCreateAPIView):
|
|||||||
testing_url = make_clickable(testing.test.name,
|
testing_url = make_clickable(testing.test.name,
|
||||||
f"/test/testdetail/{testing.test.id}?mode=exam")
|
f"/test/testdetail/{testing.test.id}?mode=exam")
|
||||||
|
|
||||||
|
news_img_path = testing.test.file.path if testing.test.file else None
|
||||||
|
if news_img_path and os.path.isfile(news_img_path):
|
||||||
|
news_img = testing.test.file
|
||||||
|
else:
|
||||||
|
news_img = os.path.join("defaultimg", "vote.png")
|
||||||
news = News(
|
news = News(
|
||||||
title="Пройдите тестирование!",
|
title="Пройдите тестирование!",
|
||||||
text=f'Пройдите тестирование "{testing_url}" до {formatted_date}',
|
text=f'Пройдите тестирование "{testing_url}" до {formatted_date}',
|
||||||
cdate=request.data["datestart"],
|
cdate=request.data["datestart"],
|
||||||
author=request.user,
|
author=request.user,
|
||||||
link=testing.test.file,
|
link=news_img,
|
||||||
# link=os.path.join("defaultimg", "testing.png"),
|
|
||||||
)
|
)
|
||||||
news.save()
|
news.save()
|
||||||
testing.news = news
|
testing.news = news
|
||||||
|
|||||||
Reference in new issue
Block a user