mirror of
https://github.com/grey-cat-1908/formaptix-server.git
synced 2024-09-22 19:52:00 +03:00
some base for form (text question)
This commit is contained in:
parent
12ee0d4e7b
commit
41b3e5bb91
4 changed files with 35 additions and 0 deletions
13
database/form.py
Normal file
13
database/form.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from sqlalchemy import JSON
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from database import Base, User
|
||||
|
||||
|
||||
class Form(Base):
|
||||
__tablename__ = "forms"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str]
|
||||
owner: Mapped[User] = relationship(User, cascade="all, delete")
|
||||
data: Mapped[dict] = mapped_column(JSON)
|
|
@ -5,6 +5,7 @@ from database import Base
|
|||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
username: Mapped[str] = mapped_column(unique=True)
|
||||
password: Mapped[str]
|
||||
|
|
21
models/form.py
Normal file
21
models/form.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from enum import Enum, auto
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from models import BaseModel
|
||||
|
||||
|
||||
class QuestionType(Enum):
|
||||
text = auto()
|
||||
|
||||
|
||||
class BaseQuestion(BaseModel):
|
||||
question_type: QuestionType
|
||||
label: str = Field(min_length=1)
|
||||
description: str | None = Field(None, min_length=1)
|
||||
|
||||
|
||||
class TextQuestion(BaseQuestion):
|
||||
question_type = QuestionType.text
|
||||
min_length: int | None = None
|
||||
max_length: int | None = None
|
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
Loading…
Reference in a new issue