def get(self): uid = self.get_user_id() user = mongo.db.user.find_one({"_id": ObjectId(uid)}) user = common_util.cursor_to_dict(user) if user.get("password"): del user["password"] return self.result_ok(user)
def get(self): """ TODO: 从ride那边获取评论信息。 """ uid = self.get_user_id() raw = mongo.db.passenger.find({"user_id": uid}) dict = common_util.cursor_to_dict(raw) return self.result_ok(dict)
def get(self): parser = reqparse.RequestParser() parser.add_argument("id", type=str, required=True) args = parser.parse_args() uid = args["id"] user = mongo.db.user.find_one({"_id": ObjectId(uid)}) user = common_util.cursor_to_dict(user) del user["password"] return self.result_ok(user)
def get(self): uid = self.get_user_id() raw2 = mongo.db.ride.find({"user.$id": ObjectId(uid)}) dict1 = common_util.cursor_to_dict(raw2) for x in dict1: x["type"] = 1 # mock request ride success info. dict1[0]["type"] = 0 return self.result_ok(dict1)
def get_comment(user_id): user = mongo.db.user.find_one({"_id": ObjectId(user_id)}) user = dict(user) comments = user.get('comment') if comments: for c in comments: commentor = mongo.db.dereference(c['commentor']) c['commentor_name'] = commentor['nickname'] comments = cursor_to_dict(comments) return comments
def get(self): parser = reqparse.RequestParser() parser.add_argument("user_id", type=str, required=True) args = parser.parse_args() raw = mongo.db.ride.find( {"user.$id": ObjectId(args["user_id"]), "user_comments": {"$exists": True}}, {"user_comments": 1} ) data = common_util.cursor_to_dict(raw) comments = [] for x in data: comments += x["user_comments"] return self.result_ok(comments)
def get(self): parser = reqparse.RequestParser() parser.add_argument('id' , type=str , required=True) args = parser.parse_args() data = ride_model.nearby_car(args['id']) data = common_util.cursor_to_dict(data) data['distance'] = distance_on_unit_sphere(data['start_loc'][0], data['start_loc'][1], data['dest_loc'][0], data['dest_loc'][1]) #Mock data['rating'] = 3 return self.result_ok(data)
def get(self): user_id = self.get_user_id() coin = mongo.db.user.find_one({"_id": ObjectId(user_id)}, {"merchant_coin": True, "ride_coin": True}) coin = common_util.cursor_to_dict(coin) return self.result_ok(coin)