create_news news_img

This commit is contained in:
cja committed 2025-06-02 17:00:31 +03:00
1 parent 920d9db693
commit 131edce551
1 file changed
+6 -2
+6 -2
View File
@@ -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", "default.jpeg")
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