This commit is contained in:
15
orm/draft.py
15
orm/draft.py
@@ -8,6 +8,11 @@ from auth.orm import Author
|
||||
from orm.base import BaseModel as Base
|
||||
from orm.topic import Topic
|
||||
|
||||
# Author уже импортирован в начале файла
|
||||
def get_author_model():
|
||||
"""Возвращает модель Author для использования в запросах"""
|
||||
return Author
|
||||
|
||||
|
||||
class DraftTopic(Base):
|
||||
__tablename__ = "draft_topic"
|
||||
@@ -28,7 +33,7 @@ class DraftAuthor(Base):
|
||||
__tablename__ = "draft_author"
|
||||
|
||||
draft: Mapped[int] = mapped_column(ForeignKey("draft.id"), index=True)
|
||||
author: Mapped[int] = mapped_column(ForeignKey(Author.id), index=True)
|
||||
author: Mapped[int] = mapped_column(ForeignKey("author.id"), index=True)
|
||||
caption: Mapped[str | None] = mapped_column(String, nullable=True, default="")
|
||||
|
||||
__table_args__ = (
|
||||
@@ -44,7 +49,7 @@ class Draft(Base):
|
||||
# required
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
created_at: Mapped[int] = mapped_column(Integer, nullable=False, default=lambda: int(time.time()))
|
||||
created_by: Mapped[int] = mapped_column(ForeignKey(Author.id), nullable=False)
|
||||
created_by: Mapped[int] = mapped_column(ForeignKey("author.id"), nullable=False)
|
||||
community: Mapped[int] = mapped_column(ForeignKey("community.id"), nullable=False, default=1)
|
||||
|
||||
# optional
|
||||
@@ -63,9 +68,9 @@ class Draft(Base):
|
||||
# auto
|
||||
updated_at: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
||||
deleted_at: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
||||
updated_by: Mapped[int | None] = mapped_column(ForeignKey(Author.id), nullable=True)
|
||||
deleted_by: Mapped[int | None] = mapped_column(ForeignKey(Author.id), nullable=True)
|
||||
authors = relationship(Author, secondary=DraftAuthor.__table__)
|
||||
updated_by: Mapped[int | None] = mapped_column(ForeignKey("author.id"), nullable=True)
|
||||
deleted_by: Mapped[int | None] = mapped_column(ForeignKey("author.id"), nullable=True)
|
||||
authors = relationship(get_author_model(), secondary=DraftAuthor.__table__)
|
||||
topics = relationship(Topic, secondary=DraftTopic.__table__)
|
||||
|
||||
# shout/publication
|
||||
|
||||
Reference in New Issue
Block a user