check-existing-on-create
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s
This commit is contained in:
parent
ac9f1d8a40
commit
a25a434ea2
|
@ -133,11 +133,16 @@ async def create_shout(_, info, inp):
|
|||
# NOTE: requesting new shout back
|
||||
shout = session.query(Shout).where(Shout.slug == slug).first()
|
||||
if shout:
|
||||
# Проверка на существование записи
|
||||
existing_sa = session.query(ShoutAuthor).filter_by(shout=shout.id, author=author_id).first()
|
||||
if not existing_sa:
|
||||
sa = ShoutAuthor(shout=shout.id, author=author_id)
|
||||
session.add(sa)
|
||||
|
||||
topics = session.query(Topic).filter(Topic.slug.in_(inp.get("topics", []))).all()
|
||||
for topic in topics:
|
||||
existing_st = session.query(ShoutTopic).filter_by(shout=shout.id, author=topic.id).first()
|
||||
if not existing_st:
|
||||
t = ShoutTopic(topic=topic.id, shout=shout.id)
|
||||
session.add(t)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user