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"],
|
||||
test_passed=False,
|
||||
)
|
||||
if request.data.get("news") == "true":
|
||||
if request.data.get("news"):
|
||||
self.create_news(request, testing)
|
||||
return Response(
|
||||
{"status": "success", "message": "Testing created successfully."},
|
||||
@@ -339,13 +339,17 @@ class TestingView(generics.ListCreateAPIView):
|
||||
testing_url = make_clickable(testing.test.name,
|
||||
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(
|
||||
title="Пройдите тестирование!",
|
||||
text=f'Пройдите тестирование "{testing_url}" до {formatted_date}',
|
||||
cdate=request.data["datestart"],
|
||||
author=request.user,
|
||||
link=testing.test.file,
|
||||
# link=os.path.join("defaultimg", "testing.png"),
|
||||
link=news_img,
|
||||
)
|
||||
news.save()
|
||||
testing.news = news
|
||||
|
||||
Reference in new issue
Block a user