Added title in about us and updated apis
This commit is contained in:
@@ -24,6 +24,7 @@ async def create_aboutUs(
|
||||
session: SessionDep,
|
||||
current_user: CurrentUser,
|
||||
description: str = Form(),
|
||||
title: str = Form(),
|
||||
image: Annotated[UploadFile, File()],
|
||||
index: int = Form()
|
||||
) -> Any:
|
||||
@@ -33,7 +34,7 @@ async def create_aboutUs(
|
||||
validate_file_size_type(image)
|
||||
imageUrl = await save_picture(file=image, folderName="tmp")
|
||||
# aboutus_in.image = imageUrl
|
||||
aboutUs_in = AboutUsCreate(description=description, image=imageUrl, index=index)
|
||||
aboutUs_in = AboutUsCreate(description=description, image=imageUrl, index=index ,title=title)
|
||||
aboutUs = AboutUs.from_orm(aboutUs_in)
|
||||
session.add(aboutUs)
|
||||
session.commit()
|
||||
@@ -49,6 +50,7 @@ async def edit_aboutUs(
|
||||
id: uuid.UUID,
|
||||
description: str = Form(),
|
||||
image: Annotated[UploadFile, File()] = None,
|
||||
title: str = Form(),
|
||||
index: int = Form()
|
||||
) -> Any:
|
||||
aboutUs = session.get(AboutUs, id)
|
||||
@@ -57,9 +59,9 @@ async def edit_aboutUs(
|
||||
validate_file_size_type(image)
|
||||
imageUrl = await save_picture(file=image, folderName="tmp")
|
||||
await del_picture(aboutUs.image)
|
||||
aboutUs_in = AboutsUpdate(description=description, image=imageUrl, index=index)
|
||||
aboutUs_in = AboutsUpdate(description=description, image=imageUrl, index=index, title=title)
|
||||
else :
|
||||
aboutUs_in = AboutsUpdate(description=description, image=aboutUs.image, index=index)
|
||||
aboutUs_in = AboutsUpdate(description=description, image=aboutUs.image, index=index, title=title)
|
||||
|
||||
update_dict = aboutUs_in.model_dump(exclude_unset=True)
|
||||
aboutUs.sqlmodel_update(update_dict)
|
||||
|
Reference in New Issue
Block a user