示例#1
0
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if id in current_user.blocked_user_id:
         User.objects(id=current_user.id) \
             .update_one(pull__blocked_user_id=id)
     return '', 204
示例#2
0
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user in current_user.following:
         User.objects(id=current_user.id) \
             .update_one(pull__following=user.to_dbref())
         User.objects(id=id) \
             .update_one(pull__follower=current_user.to_dbref())
     return '', 204
示例#3
0
 def put(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if id not in current_user.blocked_user_id:
         User.objects(id=current_user.id) \
             .update_one(push__blocked_user_id=id)
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(EXISTING)
     return status_fields, 202
示例#4
0
 def put(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user not in current_user.following:
         User.objects(id=current_user.id) \
             .update_one(push__following=user.to_dbref())
         User.objects(id=id) \
             .update_one(push__follower=current_user.to_dbref())
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(EXISTING)
     return status_fields, 202
示例#5
0
文件: user.py 项目: tmacjx/firefly
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user in current_user.following:
         current_user.update_one(pull_follwing=user)
         user.update_one(pull_follwer=current_user)
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(NOTFOUND)
     return status_fields, 204
示例#6
0
文件: user.py 项目: duoduo369/firefly
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user in current_user.following:
         current_user.update_one(pull_follwing=user)
         user.update_one(pull_follwer=current_user)
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(NOTFOUND)
     return status_fields, 204
示例#7
0
文件: app.py 项目: guoyu07/firefly
 def load_user(user_id):
     return User.objects(_id=user_id)
示例#8
0
文件: app.py 项目: pino2046/firefly-1
 def load_user(user_id):
     return User.objects(_id=user_id)