From 49a62660c1ce5a86c03351a5af494c0055bc04fa Mon Sep 17 00:00:00 2001 From: Mawoka Date: Wed, 6 Apr 2022 20:18:17 +0200 Subject: [PATCH] :bug: Fixed get public quizzes --- CONTRIBUTING.md | 3 ++- classquiz/routers/quiz.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae039d2..b3faea0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,5 +20,6 @@ an issue here on GitHub. ## 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. \ No newline at end of file diff --git a/classquiz/routers/quiz.py b/classquiz/routers/quiz.py index e786b0c..39f1522 100644 --- a/classquiz/routers/quiz.py +++ b/classquiz/routers/quiz.py @@ -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") if user is None: quiz = await Quiz.objects.get_or_none(id=quiz_id, public=True) - # TODO: User can't be none else: quiz = await Quiz.objects.get_or_none(id=quiz_id, user_id=user.id) 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: return quiz