🐛 Fixed get public quizzes
This commit is contained in:
+2
-1
@@ -20,5 +20,6 @@ an issue here on GitHub.
|
|||||||
|
|
||||||
## Want to translate?
|
## Want to translate?
|
||||||
|
|
||||||
Go to [Weblate](https://translate.mawoka.eu/projects/classquiz/frontend/). If the language isn't available, please open
|
Go to [Weblate](https://translate.mawoka.eu/projects/classquiz/frontend/).
|
||||||
|
If the language isn't available, please open
|
||||||
an issue here, so I'll be able to add it.
|
an issue here, so I'll be able to add it.
|
||||||
@@ -38,11 +38,14 @@ async def get_quiz_from_id(quiz_id: str, user: User | None = Depends(get_current
|
|||||||
raise HTTPException(status_code=400, detail="badly formed quiz id")
|
raise HTTPException(status_code=400, detail="badly formed quiz id")
|
||||||
if user is None:
|
if user is None:
|
||||||
quiz = await Quiz.objects.get_or_none(id=quiz_id, public=True)
|
quiz = await Quiz.objects.get_or_none(id=quiz_id, public=True)
|
||||||
# TODO: User can't be none
|
|
||||||
else:
|
else:
|
||||||
quiz = await Quiz.objects.get_or_none(id=quiz_id, user_id=user.id)
|
quiz = await Quiz.objects.get_or_none(id=quiz_id, user_id=user.id)
|
||||||
if quiz is None:
|
if quiz is None:
|
||||||
return JSONResponse(status_code=404, content={"detail": "quiz not found"})
|
public_quiz = await Quiz.objects.get_or_none(id=quiz_id, public=True)
|
||||||
|
if public_quiz is None:
|
||||||
|
return JSONResponse(status_code=404, content={"detail": "quiz not found"})
|
||||||
|
else:
|
||||||
|
return public_quiz
|
||||||
else:
|
else:
|
||||||
return quiz
|
return quiz
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user