some fixes

This commit is contained in:
grey-cat-1908 2024-08-20 17:07:11 +00:00
parent 14f64a2817
commit 4c06904661
2 changed files with 4 additions and 3 deletions

View file

@ -34,7 +34,7 @@ class BaseQuestion(BaseModel):
question_type: QuestionType question_type: QuestionType
label: str = Field(min_length=1) label: str = Field(min_length=1)
description: str | None = Field(None, min_length=1) description: str | None = Field(None, min_length=1)
image_url: str | None image_url: str | None = None
required: bool = True required: bool = True
@field_serializer("id") @field_serializer("id")

View file

@ -74,10 +74,11 @@ async def user_forms(user: User):
@router.get("/get") @router.get("/get")
async def get_form(id: int) -> Form: async def get_form(id: int) -> Form | None:
async with database.sessions.begin() as session: async with database.sessions.begin() as session:
stmt = select(database.Form).where(database.Form.id == id) stmt = select(database.Form).where(database.Form.id == id)
db_request = await session.execute(stmt) db_request = await session.execute(stmt)
form = db_request.scalar_one_or_none() form = db_request.scalar_one_or_none()
return Form.model_validate(form) if form is not None:
return Form.model_validate(form)