def get(self): id = self.get_secure_cookie("id") data = {} data[KEY.ID] = int(id) data[KEY.STATE] = 0 allRelationUser = db.query_follow(data) # print(allRelationUser) user_Info = db.get_user_information(data) if (allRelationUser != -1): family = [ elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 0 ] neighbour = [ elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 1 ] career = [ elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 2 ] # avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png" self.render("Ralationship.html", family=family, neighbour=neighbour, career=career) else: self.write("error")
def post(self): params = utils.decode_params(self.request) resp = {} if KEY.OPERATION not in params: resp[KEY.STATUS] = STATUS.ERROR elif params[KEY.OPERATION] == 0: if db.remove_static_relation(params): resp[KEY.STATUS] = STATUS.OK else: resp[KEY.STATUS] = STATUS.ERROR elif params[KEY.OPERATION] == 1: if db.add_static_relation(params): resp[KEY.STATUS] = STATUS.OK else: resp[KEY.STATUS] = STATUS.ERROR elif params[KEY.OPERATION] == 2: resp[KEY.USER_LIST] = db.query_follow(params) if resp[KEY.USER_LIST] == -1: resp[KEY.STATUS] = STATUS.ERROR else: resp[KEY.STATUS] = STATUS.OK elif params[KEY.OPERATION] == 3: relation = db.get_relation(params) if relation == -1: resp[KEY.STATUS] = STATUS.ERROR else: resp[KEY.TYPE] = relation resp[KEY.STATUS] = STATUS.OK else: resp[KEY.STATUS] = STATUS.ERROR self.write(json_encode(resp))
def post(self): params = utils.decode_params(self.request) resp = {} if KEY.OPERATION not in params: resp[KEY.STATUS] = STATUS.ERROR elif params[KEY.OPERATION] == 0: if db.remove_static_relation(params): resp[KEY.STATUS] = STATUS.OK else: resp[KEY.STATUS] = STATUS.ERROR elif params[KEY.OPERATION] == 1: if db.add_static_relation(params): resp[KEY.STATUS] = STATUS.OK else: resp[KEY.STATUS] = STATUS.ERROR elif params[KEY.OPERATION] == 2: resp[KEY.USER_LIST] = db.query_follow(params) if resp[KEY.USER_LIST] == -1: resp[KEY.STATUS] = STATUS.ERROR else: resp[KEY.STATUS] = STATUS.OK elif params[KEY.OPERATION] == 3: relation = db.get_relation(params) if relation == -1: resp[KEY.STATUS] = STATUS.ERROR else: resp[KEY.TYPE] = relation resp[KEY.STATUS] = STATUS.OK else: resp[KEY.STATUS] = STATUS.ERROR self.write(json_encode(resp))
def post(self): params = utils.decode_params(self.request) resp = {} user_info = db.get_user_information(params) if user_info is None: resp[KEY.STATUS] = STATUS.ERROR else: follow = {} follow[KEY.ID] = user_info[KEY.ID] follow[KEY.STATE] = 0 user_info[KEY.FOLLOW] = len(db.query_follow(follow)) follow[KEY.STATE] = 1 user_info[KEY.FOLLOWER] = len(db.query_follow(follow)) resp.update(user_info) resp[KEY.STATUS] = STATUS.OK self.write(json_encode(resp))
def post(self): params = utils.decode_params(self.request) resp = {} resp[KEY.USER_LIST] = db.query_follow(params) if resp[KEY.USER_LIST] == -1: resp[KEY.STATUS] = STATUS.ERROR else: resp[KEY.STATUS] = STATUS.OK self.write(json_encode(resp))
def post(self): params = utils.decode_params(self.request) resp = {} resp[KEY.USER_LIST] = db.query_follow(params) if resp[KEY.USER_LIST] == -1: resp[KEY.STATUS] = STATUS.ERROR else: resp[KEY.STATUS] = STATUS.OK self.write(json_encode(resp))
def get(self): id = self.get_secure_cookie("id") data = {} data[KEY.ID] = int(id) data[KEY.STATE] = 0 allRelationUser = db.query_follow(data); # print(allRelationUser) user_Info = db.get_user_information(data) if (allRelationUser != -1): family = [elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 0] neighbour = [elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 1] career = [elem for elem in allRelationUser if elem[KEY.RELATION_TYPE] == 2] # avatar = user_Info[KEY.AVATAR] if user_Info[KEY.AVATAR] else "default.png" self.render("Ralationship.html", family = family, neighbour = neighbour, career = career) else: self.write("error")