typo-fix
All checks were successful
Deploy on push / deploy (push) Successful in 24s

This commit is contained in:
Untone 2024-05-05 00:00:58 +03:00
parent dc791d4e7a
commit c9205a698f
2 changed files with 17 additions and 15 deletions

View File

@ -150,7 +150,7 @@ async def load_authors_by(_, _info, by, limit, offset):
q = q.limit(limit).offset(offset)
authors_nostat = local_session().session(q)
authors_nostat = local_session().execute(q)
authors = []
if authors_nostat:
for [a] in authors_nostat:

View File

@ -175,26 +175,28 @@ def prepare_new_rating(reaction: dict, shout_id: int, session, author_id: int):
Reaction.shout == shout_id,
Reaction.created_by == author_id,
Reaction.kind.in_(RATING_REACTIONS),
Reaction.deleted_at.is_not(None),
)
)
reply_to = reaction.get("reply_to")
if reply_to and isinstance(reply_to, int):
q = q.filter(Reaction.reply_to == reply_to)
rating_reactions = session.execute(q).all()
same_rating = filter(
lambda r: r.created_by == author_id and r.kind == kind,
rating_reactions,
)
opposite_rating = filter(
lambda r: r.created_by == author_id and r.kind == opposite_kind,
rating_reactions,
)
if same_rating:
return {"error": "You can't rate the same thing twice"}
elif opposite_rating:
return {"error": "Remove opposite vote first"}
elif filter(lambda r: r.created_by == author_id, rating_reactions):
return {"error": "You can't rate your own thing"}
if rating_reactions:
same_rating = filter(
lambda r: r.created_by == author_id and r.kind == kind,
rating_reactions,
)
opposite_rating = filter(
lambda r: r.created_by == author_id and r.kind == opposite_kind,
rating_reactions,
)
if same_rating:
return {"error": "You can't rate the same thing twice"}
elif opposite_rating:
return {"error": "Remove opposite vote first"}
elif filter(lambda r: r.created_by == author_id, rating_reactions):
return {"error": "You can't rate your own thing"}
return