This commit is contained in:
parent
dc791d4e7a
commit
c9205a698f
|
@ -150,7 +150,7 @@ async def load_authors_by(_, _info, by, limit, offset):
|
||||||
|
|
||||||
q = q.limit(limit).offset(offset)
|
q = q.limit(limit).offset(offset)
|
||||||
|
|
||||||
authors_nostat = local_session().session(q)
|
authors_nostat = local_session().execute(q)
|
||||||
authors = []
|
authors = []
|
||||||
if authors_nostat:
|
if authors_nostat:
|
||||||
for [a] in authors_nostat:
|
for [a] in authors_nostat:
|
||||||
|
|
|
@ -175,26 +175,28 @@ def prepare_new_rating(reaction: dict, shout_id: int, session, author_id: int):
|
||||||
Reaction.shout == shout_id,
|
Reaction.shout == shout_id,
|
||||||
Reaction.created_by == author_id,
|
Reaction.created_by == author_id,
|
||||||
Reaction.kind.in_(RATING_REACTIONS),
|
Reaction.kind.in_(RATING_REACTIONS),
|
||||||
|
Reaction.deleted_at.is_not(None),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
reply_to = reaction.get("reply_to")
|
reply_to = reaction.get("reply_to")
|
||||||
if reply_to and isinstance(reply_to, int):
|
if reply_to and isinstance(reply_to, int):
|
||||||
q = q.filter(Reaction.reply_to == reply_to)
|
q = q.filter(Reaction.reply_to == reply_to)
|
||||||
rating_reactions = session.execute(q).all()
|
rating_reactions = session.execute(q).all()
|
||||||
same_rating = filter(
|
if rating_reactions:
|
||||||
lambda r: r.created_by == author_id and r.kind == kind,
|
same_rating = filter(
|
||||||
rating_reactions,
|
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,
|
opposite_rating = filter(
|
||||||
rating_reactions,
|
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"}
|
if same_rating:
|
||||||
elif opposite_rating:
|
return {"error": "You can't rate the same thing twice"}
|
||||||
return {"error": "Remove opposite vote first"}
|
elif opposite_rating:
|
||||||
elif filter(lambda r: r.created_by == author_id, rating_reactions):
|
return {"error": "Remove opposite vote first"}
|
||||||
return {"error": "You can't rate your own thing"}
|
elif filter(lambda r: r.created_by == author_id, rating_reactions):
|
||||||
|
return {"error": "You can't rate your own thing"}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user