draft-creator-adding
All checks were successful
Deploy on push / deploy (push) Successful in 47s

This commit is contained in:
Untone 2025-04-27 09:15:07 +03:00
parent 20fd40df0e
commit b735bf8cab

View File

@ -95,8 +95,7 @@ async def load_drafts(_, info):
joinedload(Draft.topics),
joinedload(Draft.authors)
)
# Фильтруем по ID автора (создатель или соавтор)
.filter(or_(Draft.authors.any(Author.id == author_id), Draft.created_by == author_id))
.filter(Draft.authors.any(Author.id == author_id))
.all()
)
@ -171,6 +170,12 @@ async def create_draft(_, info, draft_input):
draft_input["created_by"] = author_id
draft = Draft(**draft_input)
session.add(draft)
session.flush()
# Добавляем создателя как автора
da = DraftAuthor(shout=draft.id, author=author_id)
session.add(da)
session.commit()
return {"draft": draft}
except Exception as e: