mirror of
https://github.com/grey-cat-1908/formaptix-server.git
synced 2024-11-11 18:57:27 +03:00
some fixes
This commit is contained in:
parent
14f64a2817
commit
4c06904661
2 changed files with 4 additions and 3 deletions
|
@ -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")
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue