Untested Ormar and FastAPI update

This commit is contained in:
Mawoka
2025-05-20 12:12:06 +02:00
parent 2bfd73412d
commit 03e85f8586
31 changed files with 719 additions and 694 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ from asyncio import run
async def main():
kahoot_quiz: _Response = await get("GAME_ID")
print(kahoot_quiz.json(exclude={"kahoot"}))
print(kahoot_quiz.model_dump_json(exclude={"kahoot"}))
run(main())
```
@@ -35,7 +35,7 @@ from asyncio import run
async def main():
kahoot_quizzes: _Response = await search("QUERY")
print(kahoot_quizzes.json())
print(kahoot_quizzes.model_dump_json())
run(main())
```
+32 -32
View File
@@ -10,19 +10,19 @@ from pydantic import BaseModel
class _CoverMetadata(BaseModel):
id: UUID | None
resources: str | None
id: UUID | None = None
resources: str | None = None
class _CreatorAvatar(BaseModel):
url: str | None
id: UUID | None
type: str | None
bitmojiAvatarId: str | None
altText: str | None
contentType: str | None
width: int | None
height: int | None
url: str | None = None
id: UUID | None = None
type: str | None = None
bitmojiAvatarId: str | None = None
altText: str | None = None
contentType: str | None = None
width: int | None = None
height: int | None = None
class _LastEdit(BaseModel):
@@ -32,7 +32,7 @@ class _LastEdit(BaseModel):
class _ImageMetadata(BaseModel):
id: UUID | None
id: UUID | None = None
content_type: Optional[str]
width: Optional[int]
height: Optional[int]
@@ -40,11 +40,11 @@ class _ImageMetadata(BaseModel):
class _SampleQuestion(BaseModel):
image: str | None
imageMetadata: _ImageMetadata | None
image: str | None = None
imageMetadata: _ImageMetadata | None = None
title: str
type: str
time: int | None
time: int | None = None
class _Access(BaseModel):
@@ -57,19 +57,19 @@ class _Card(BaseModel):
title: str
description: str
slug: str
cover: str | None
coverMetadata: _CoverMetadata | dict[None, None] | None
cover: str | None = None
coverMetadata: _CoverMetadata | dict[None, None] | None = None
draftExists: bool
inventoryItemIds: List[Any]
number_of_questions: int
creator: UUID
creator_username: str
creator_avatar: _CreatorAvatar | dict[None, None] | None
creator_avatar: _CreatorAvatar | dict[None, None] | None = None
badges: List[str]
visibility: int
locked: bool
writeProtection: bool
lastEdit: _LastEdit | None
lastEdit: _LastEdit | None = None
featured: bool
young_featured: bool
sponsored: bool
@@ -111,8 +111,8 @@ class _LanguageInfo(BaseModel):
class _Metadata(BaseModel):
access: _Access
duplicationProtection: bool | None
lastEdit: _LastEdit | None
duplicationProtection: bool | None = None
lastEdit: _LastEdit | None = None
class _Parent(BaseModel):
@@ -123,7 +123,7 @@ class _Parent(BaseModel):
class _Choice(BaseModel):
answer: str
correct: bool
languageInfo: _LanguageInfo | None
languageInfo: _LanguageInfo | None = None
class _Video(BaseModel):
@@ -141,12 +141,12 @@ class _Question(BaseModel):
points: bool
pointsMultiplier: int
choices: List[_Choice]
image: str | None
imageMetadata: _ImageMetadata | None
image: str | None = None
imageMetadata: _ImageMetadata | None = None
resources: Optional[str]
video: _Video
questionFormat: int
languageInfo: _LanguageInfo | None
languageInfo: _LanguageInfo | None = None
media: List[Any]
@@ -157,23 +157,23 @@ class _Kahoot(BaseModel):
creator_username: str
compatibilityLevel: int
creator_primary_usage: str
folderId: UUID | None
folderId: UUID | None = None
visibility: int
difficulty: int | None
difficulty: int | None = None
audience: str
audience: str
title: str
description: str
quizType: str
tags: str | None | List[str]
cover: str | None
coverMetadata: _CoverMetadata | dict[None, None] | None
tags: str | None | List[str] = None
cover: str | None = None
coverMetadata: _CoverMetadata | dict[None, None] | None = None
questions: List[_Question]
metadata: _Metadata
parent: _Parent | None
resources: str | None
parent: _Parent | None = None
resources: str | None = None
slug: str
languageInfo: _LanguageInfo | None
languageInfo: _LanguageInfo | None = None
inventoryItemIds: List[Any]
type: str
created: int
+1 -1
View File
@@ -87,7 +87,7 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | int:
answers=answers,
time=str(q.time / 1000),
image=image,
).dict()
).model_dump()
)
cover = None
if quiz.kahoot.cover != "" and quiz.kahoot.cover is not None:
+1 -1
View File
@@ -15,7 +15,7 @@ from classquiz.kahoot_importer import _Entity
class _Response(BaseModel):
entities: List[_Entity]
totalHits: int
cursor: int | None
cursor: int | None = None
pageTimestamp: int