WIP checkpoint: T1: Moderation data model + Alembic migration
This commit is contained in:
@@ -8,7 +8,7 @@ from sqlalchemy.ext.asyncio import create_async_engine
|
|||||||
|
|
||||||
from app.config import settings
|
from app.config import settings
|
||||||
from app.database import Base
|
from app.database import Base
|
||||||
from app.models import user, session, world, asset # noqa: F401
|
from app.models import user, session, world, asset, report, moderation_action, appeal # noqa: F401
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
|
|||||||
@@ -22,13 +22,6 @@ from app.database import Base
|
|||||||
class Appeal(Base):
|
class Appeal(Base):
|
||||||
__tablename__ = "appeals"
|
__tablename__ = "appeals"
|
||||||
|
|
||||||
# Status values
|
|
||||||
APPEAL_STATUS = Enum(
|
|
||||||
"pending", "approved", "rejected",
|
|
||||||
name="appeal_status",
|
|
||||||
create_type=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
moderation_action_id = Column(
|
moderation_action_id = Column(
|
||||||
Integer,
|
Integer,
|
||||||
@@ -42,9 +35,9 @@ class Appeal(Base):
|
|||||||
)
|
)
|
||||||
reason = Column(Text, nullable=False)
|
reason = Column(Text, nullable=False)
|
||||||
status = Column(
|
status = Column(
|
||||||
APPEAL_STATUS,
|
Enum("pending", "approved", "rejected", name="appeal_status", create_type=False),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=APPEAL_STATUS.PENDING,
|
default="pending",
|
||||||
)
|
)
|
||||||
reviewed_by = Column(
|
reviewed_by = Column(
|
||||||
Integer,
|
Integer,
|
||||||
@@ -63,7 +56,7 @@ class Appeal(Base):
|
|||||||
reviewer = relationship(
|
reviewer = relationship(
|
||||||
"User",
|
"User",
|
||||||
foreign_keys=[reviewed_by],
|
foreign_keys=[reviewed_by],
|
||||||
backref="reviewed_appeals",
|
back_populates="reviewed_appeals",
|
||||||
)
|
)
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
|||||||
@@ -111,3 +111,8 @@ class ModerationAction(Base):
|
|||||||
back_populates="moderation_actions_received",
|
back_populates="moderation_actions_received",
|
||||||
)
|
)
|
||||||
report = relationship("Report", back_populates="moderation_actions")
|
report = relationship("Report", back_populates="moderation_actions")
|
||||||
|
appeals = relationship(
|
||||||
|
"Appeal",
|
||||||
|
back_populates="moderation_action",
|
||||||
|
cascade="all, delete-orphan",
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user