Add poll workflow and signed participation support
This commit is contained in:
@@ -39,6 +39,11 @@ class Poll(Base, TimestampMixin):
|
||||
status: Mapped[str] = mapped_column(String(30), default="draft", nullable=False, index=True)
|
||||
visibility: Mapped[str] = mapped_column(String(30), default="private", nullable=False, index=True)
|
||||
result_visibility: Mapped[str] = mapped_column(String(30), default="after_close", nullable=False)
|
||||
context_module: Mapped[str | None] = mapped_column(String(100), nullable=True, index=True)
|
||||
context_resource_type: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
||||
context_resource_id: Mapped[str | None] = mapped_column(String(255), nullable=True, index=True)
|
||||
workflow_state: Mapped[str | None] = mapped_column(String(100), nullable=True, index=True)
|
||||
workflow_steps: Mapped[list[dict[str, Any]]] = mapped_column(JSON, default=list, nullable=False)
|
||||
allow_anonymous: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
allow_response_update: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
min_choices: Mapped[int] = mapped_column(Integer, default=1, nullable=False)
|
||||
@@ -54,6 +59,7 @@ class Poll(Base, TimestampMixin):
|
||||
|
||||
options: Mapped[list["PollOption"]] = relationship(back_populates="poll", cascade="all, delete-orphan", order_by="PollOption.position")
|
||||
responses: Mapped[list["PollResponse"]] = relationship(back_populates="poll", cascade="all, delete-orphan")
|
||||
invitations: Mapped[list["PollInvitation"]] = relationship(back_populates="poll", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class PollOption(Base, TimestampMixin):
|
||||
@@ -98,4 +104,27 @@ class PollResponse(Base, TimestampMixin):
|
||||
poll: Mapped[Poll] = relationship(back_populates="responses")
|
||||
|
||||
|
||||
__all__ = ["Poll", "PollOption", "PollResponse", "new_uuid"]
|
||||
class PollInvitation(Base, TimestampMixin):
|
||||
__tablename__ = "poll_invitations"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("token_hash", name="uq_poll_invitations_token_hash"),
|
||||
Index("ix_poll_invitations_poll", "tenant_id", "poll_id"),
|
||||
Index("ix_poll_invitations_poll_email", "poll_id", "email"),
|
||||
)
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=new_uuid)
|
||||
tenant_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
|
||||
poll_id: Mapped[str] = mapped_column(ForeignKey("poll_polls.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
token_hash: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
||||
respondent_id: Mapped[str | None] = mapped_column(String(255), nullable=True, index=True)
|
||||
respondent_label: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
||||
email: Mapped[str | None] = mapped_column(String(320), nullable=True, index=True)
|
||||
expires_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True)
|
||||
revoked_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True)
|
||||
last_used_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
metadata_: Mapped[dict[str, Any] | None] = mapped_column("metadata", JSON, nullable=True)
|
||||
|
||||
poll: Mapped[Poll] = relationship(back_populates="invitations")
|
||||
|
||||
|
||||
__all__ = ["Poll", "PollInvitation", "PollOption", "PollResponse", "new_uuid"]
|
||||
|
||||
Reference in New Issue
Block a user