Added title in about us and updated apis
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""add title in aboutUs
|
||||
|
||||
Revision ID: 94afd163eba3
|
||||
Revises: 8e38378fd2f3
|
||||
Create Date: 2024-10-05 10:26:21.093141
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '94afd163eba3'
|
||||
down_revision = '8e38378fd2f3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('aboutus', sa.Column('title', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('aboutus', 'title')
|
||||
# ### end Alembic commands ###
|
@@ -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)
|
||||
|
@@ -26,7 +26,7 @@ if settings.BACKEND_CORS_ORIGINS:
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS
|
||||
] + ["http://localhost:3000"],
|
||||
] + ["http://localhost:3000"]+["http://localhost:5173"]+["http://localhost:5173/aboutUs"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
@@ -166,6 +166,7 @@ class Setting(SettingBase, table=True):
|
||||
class AboutUsBase(SQLModel):
|
||||
description: str = Field(max_length=1024)
|
||||
image:str | None = Field(default=None, max_length=255)
|
||||
title: str = Field(max_length=255)
|
||||
index: int
|
||||
|
||||
class AboutUsCreate(AboutUsBase):
|
||||
@@ -209,6 +210,8 @@ class CoursePublic(CourseBase):
|
||||
id: uuid.UUID
|
||||
title: str
|
||||
images: list["Image"]
|
||||
info_images: list["Info_Image"]
|
||||
schedule: list["Schedule"]
|
||||
created_at: datetime
|
||||
|
||||
class CoursesPublic(SQLModel):
|
||||
|
Reference in New Issue
Block a user