add rateUser
This commit is contained in:
parent
08c00d950f
commit
411470e5ef
|
@ -81,6 +81,29 @@ async def user_subscribers(_, info, slug):
|
|||
where(AuthorSubscription.author == slug)
|
||||
return users
|
||||
|
||||
@mutation.field("rateUser")
|
||||
@login_required
|
||||
async def rate_user(_, info, slug, value):
|
||||
user = info.context["request"].user
|
||||
|
||||
with local_session() as session:
|
||||
rating = session.query(UserRating).\
|
||||
filter(and_(UserRating.rater == user.slug, UserRating.user == slug)).\
|
||||
first()
|
||||
|
||||
if rating:
|
||||
rating.value = value
|
||||
session.commit()
|
||||
return {}
|
||||
|
||||
UserRating.create(
|
||||
rater = user.slug,
|
||||
user = slug,
|
||||
value = value
|
||||
)
|
||||
|
||||
return {}
|
||||
|
||||
@mutation.field("authorSubscribe")
|
||||
@login_required
|
||||
async def author_subscribe(_, info, slug):
|
||||
|
|
|
@ -132,7 +132,7 @@ type Mutation {
|
|||
viewShout(slug: String!): Result!
|
||||
|
||||
# user profile
|
||||
# rateUser(value: Int!): Result!
|
||||
rateUser(slug: String!, value: Int!): Result!
|
||||
# updateOnlineStatus: Result!
|
||||
updateProfile(profile: ProfileInput!): Result!
|
||||
|
||||
|
@ -166,7 +166,6 @@ type Query {
|
|||
# profile
|
||||
getCurrentUser: UserResult!
|
||||
getUsersBySlugs(slugs: [String]!): [User]!
|
||||
# rateUser(shout: Int): Int!
|
||||
getUserRoles(slug: String!): [Role]!
|
||||
userComments(slug: String!, page: Int!, size: Int!): [Comment]!
|
||||
userSubscriptions(slug: String!): [User]!
|
||||
|
|
Loading…
Reference in New Issue
Block a user