rate comment
This commit is contained in:
parent
a07ada7de0
commit
36a0770675
|
@ -55,3 +55,24 @@ async def delete_comment(_, info, id):
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@mutation.field("rateComment")
|
||||||
|
@login_required
|
||||||
|
async def rate_comment(_, info, id, value):
|
||||||
|
auth = info.context["request"].auth
|
||||||
|
user_id = auth.user_id
|
||||||
|
|
||||||
|
with local_session() as session:
|
||||||
|
rating = session.query(CommentRating).\
|
||||||
|
filter(CommentRating.comment_id == id and CommentRating.createdBy == user_id).first()
|
||||||
|
if rating:
|
||||||
|
rating.value = value
|
||||||
|
session.commit()
|
||||||
|
return {}
|
||||||
|
|
||||||
|
CommentRating.create(
|
||||||
|
comment_id = id,
|
||||||
|
createdBy = user_id,
|
||||||
|
value = value)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
|
@ -88,6 +88,7 @@ type Mutation {
|
||||||
createComment(body: String!, shout: Int!, replyTo: Int): CommentResult!
|
createComment(body: String!, shout: Int!, replyTo: Int): CommentResult!
|
||||||
updateComment(id: Int!, body: String!): CommentResult!
|
updateComment(id: Int!, body: String!): CommentResult!
|
||||||
deleteComment(id: Int!): Result!
|
deleteComment(id: Int!): Result!
|
||||||
|
rateComment(id: Int!, value: Int!): Result!
|
||||||
}
|
}
|
||||||
|
|
||||||
################################### Query
|
################################### Query
|
||||||
|
|
Loading…
Reference in New Issue
Block a user