This commit is contained in:
parent
20fd40df0e
commit
b735bf8cab
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user