rating-fix
This commit is contained in:
parent
e2e85376f0
commit
3a6c805bcf
|
@ -213,7 +213,6 @@ async def create_reaction(_, info, reaction):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
shout = session.query(Shout).filter(Shout.id == shout_id).one()
|
shout = session.query(Shout).filter(Shout.id == shout_id).one()
|
||||||
author = session.query(Author).filter(Author.user == user_id).first()
|
author = session.query(Author).filter(Author.user == user_id).first()
|
||||||
dont_create_new = False
|
|
||||||
if shout and author:
|
if shout and author:
|
||||||
reaction["created_by"] = author.id
|
reaction["created_by"] = author.id
|
||||||
kind = reaction.get("kind")
|
kind = reaction.get("kind")
|
||||||
|
@ -240,7 +239,7 @@ async def create_reaction(_, info, reaction):
|
||||||
)
|
)
|
||||||
|
|
||||||
if same_reaction is not None:
|
if same_reaction is not None:
|
||||||
return {"error": "You can't vote twice"}
|
return {"error": "You can't like or dislike same thing twice"}
|
||||||
|
|
||||||
opposite_reaction_kind = (
|
opposite_reaction_kind = (
|
||||||
ReactionKind.DISLIKE.value
|
ReactionKind.DISLIKE.value
|
||||||
|
@ -261,9 +260,7 @@ async def create_reaction(_, info, reaction):
|
||||||
)
|
)
|
||||||
|
|
||||||
if opposite_reaction is not None:
|
if opposite_reaction is not None:
|
||||||
await notify_reaction(opposite_reaction, "delete")
|
return {"error": "Remove opposite vote first"}
|
||||||
session.delete(opposite_reaction)
|
|
||||||
return {}
|
|
||||||
else:
|
else:
|
||||||
rdict = await _create_reaction(session, shout, author, reaction)
|
rdict = await _create_reaction(session, shout, author, reaction)
|
||||||
return {"reaction": rdict}
|
return {"reaction": rdict}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user