Updated courses model and fixed rich text editor tool bar drop down problem
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""update course string max length
|
||||
|
||||
Revision ID: 01b284ceabf9
|
||||
Revises: 71a20fad83f9
|
||||
Create Date: 2024-10-01 12:59:07.159639
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '01b284ceabf9'
|
||||
down_revision = '71a20fad83f9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('course', 'long_description',
|
||||
existing_type=sa.VARCHAR(length=2048),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=8192),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'information',
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=8192),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'contant',
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=8192),
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('course', 'contant',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=8192),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'information',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=8192),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'long_description',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=8192),
|
||||
type_=sa.VARCHAR(length=2048),
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
@@ -0,0 +1,67 @@
|
||||
"""update course string max length
|
||||
|
||||
Revision ID: 8e38378fd2f3
|
||||
Revises: 01b284ceabf9
|
||||
Create Date: 2024-10-01 13:11:16.073772
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8e38378fd2f3'
|
||||
down_revision = '01b284ceabf9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('course', 'sort_description',
|
||||
existing_type=sa.VARCHAR(length=1024),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'long_description',
|
||||
existing_type=sa.VARCHAR(length=8192),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'information',
|
||||
existing_type=sa.VARCHAR(length=8192),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'contant',
|
||||
existing_type=sa.VARCHAR(length=8192),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'remark',
|
||||
existing_type=sa.VARCHAR(length=512),
|
||||
type_=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('course', 'remark',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
type_=sa.VARCHAR(length=512),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'contant',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
type_=sa.VARCHAR(length=8192),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'information',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
type_=sa.VARCHAR(length=8192),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'long_description',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
type_=sa.VARCHAR(length=8192),
|
||||
existing_nullable=False)
|
||||
op.alter_column('course', 'sort_description',
|
||||
existing_type=sqlmodel.sql.sqltypes.AutoString(length=32768),
|
||||
type_=sa.VARCHAR(length=1024),
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
@@ -26,10 +26,11 @@ if settings.BACKEND_CORS_ORIGINS:
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS
|
||||
],
|
||||
] + ["http://localhost:3000"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
)
|
||||
|
||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
||||
|
@@ -186,11 +186,11 @@ class AboutsListPublic(SQLModel):
|
||||
|
||||
class CourseBase(SQLModel):
|
||||
title: str = Field(max_length=255)
|
||||
sort_description: str = Field(max_length=1024)
|
||||
long_description: str = Field(max_length=2048)
|
||||
information: str = Field(max_length=1024)
|
||||
contant: str = Field(max_length=1024)
|
||||
remark: str = Field(max_length=512)
|
||||
sort_description: str = Field(max_length=32768)
|
||||
long_description: str = Field(max_length=32768)
|
||||
information: str = Field(max_length=32768)
|
||||
contant: str = Field(max_length=32768)
|
||||
remark: str = Field(max_length=32768)
|
||||
|
||||
class CourseCreate(CourseBase):
|
||||
pass
|
||||
@@ -208,6 +208,7 @@ class Course(CourseBase, table=True):
|
||||
class CoursePublic(CourseBase):
|
||||
id: uuid.UUID
|
||||
title: str
|
||||
images: list["Image"]
|
||||
created_at: datetime
|
||||
|
||||
class CoursesPublic(SQLModel):
|
||||
@@ -219,6 +220,10 @@ class CoursesPublic(SQLModel):
|
||||
class ImageBase(SQLModel):
|
||||
image: str = Field(max_length=255)
|
||||
index: int
|
||||
|
||||
|
||||
class ImagePublic(ImageBase):
|
||||
id: uuid.UUID
|
||||
|
||||
class ImageCreate(ImageBase):
|
||||
course_id: uuid.UUID
|
||||
@@ -227,6 +232,7 @@ class Image(ImageBase, table=True):
|
||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||
course_id: uuid.UUID = Field(foreign_key="course.id", nullable=False, ondelete="CASCADE")
|
||||
course: Course | None = Relationship(back_populates="images")
|
||||
|
||||
|
||||
|
||||
class Info_ImageBase(SQLModel):
|
||||
|
Reference in New Issue
Block a user