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