import-fix
All checks were successful
deploy / deploy (push) Successful in 1m55s

This commit is contained in:
2023-12-17 07:59:16 +03:00
parent cd0ba88462
commit 4697b44504
5 changed files with 14 additions and 11 deletions

View File

@@ -145,9 +145,17 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False):
# main topic
# TODO: test main_topic update
if "main_topic" in shout_input:
old_main_topic = session.query(ShoutTopic).filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.main == True)).first()
old_main_topic = (
session.query(ShoutTopic)
.filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.main == True))
.first()
)
main_topic = session.query(Topic).filter(Topic.slug == shout_input["main_topic"]).first()
new_main_topic = session.query(ShoutTopic).filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.topic == main_topic.id)).first()
new_main_topic = (
session.query(ShoutTopic)
.filter(and_(ShoutTopic.shout == shout.id, ShoutTopic.topic == main_topic.id))
.first()
)
if old_main_topic is not new_main_topic:
old_main_topic.main = False
new_main_topic.main = True