Merge pull request #199 from learnhouse/feat/fix-model-dump-issues

Use dictionary serialization instead of model_dump()
This commit is contained in:
Badr B 2024-04-06 13:55:47 +02:00 committed by GitHub
commit cbbfc288c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 9 additions and 7 deletions

View file

@ -8,7 +8,7 @@ router = APIRouter()
@router.get("/config")
async def config():
config = get_learnhouse_config()
return config.model_dump()
return config.dict()

View file

@ -54,7 +54,7 @@ async def create_image_block(
block = Block(
activity_id=activity.id if activity.id else 0,
block_type=BlockTypeEnum.BLOCK_IMAGE,
content=block_data.model_dump(),
content=block_data.dict(),
org_id=org.id if org.id else 0,
course_id=course.id if course.id else 0,
block_uuid=block_uuid,

View file

@ -55,7 +55,7 @@ async def create_pdf_block(
block = Block(
activity_id=activity.id if activity.id else 0,
block_type=BlockTypeEnum.BLOCK_DOCUMENT_PDF,
content=block_data.model_dump(),
content=block_data.dict(),
org_id=org.id if org.id else 0,
course_id=course.id if course.id else 0,
block_uuid=block_uuid,

View file

@ -55,7 +55,7 @@ async def create_video_block(
block = Block(
activity_id=activity.id if activity.id else 0,
block_type=BlockTypeEnum.BLOCK_VIDEO,
content=block_data.model_dump(),
content=block_data.dict(),
org_id=org.id if org.id else 0,
course_id=course.id if course.id else 0,
block_uuid=block_uuid,

View file

@ -326,6 +326,8 @@ async def get_courses_orgslug(
page: int = 1,
limit: int = 10,
):
# TODO : This entire function is a mess. It needs to be rewritten.
# Query for public courses
statement_public = (

View file

@ -279,9 +279,9 @@ async def install_default_elements(db_session: Session):
)
# Serialize rights to JSON
role_global_admin.rights = role_global_admin.rights.model_dump() # type: ignore
role_global_maintainer.rights = role_global_maintainer.rights.model_dump() # type: ignore
role_global_user.rights = role_global_user.rights.model_dump() # type: ignore
role_global_admin.rights = role_global_admin.rights.dict() # type: ignore
role_global_maintainer.rights = role_global_maintainer.rights.dict() # type: ignore
role_global_user.rights = role_global_user.rights.dict() # type: ignore
# Insert roles in DB
db_session.add(role_global_admin)