def edit_user_info_page(): if request.method == "GET": user_id = session.get("user_id") user = User.get_user_info(g.db, user_id) if user is None: return jsonify(status="false") user_info = dict() user_info["status"] = "success" user_info["type"] = str(user.type) user_info["engname"] = user.username user_info["pic"] = user.pic user_info["phonenum"] = user.phone user_info["email"] = user.email # user_info["password"] = user.password user_info["universityname"] = user.prevuniversity user_info["majorname"] = user.prevmajor score = Score.get_user_score(g.db, user_id) if score is None: return json.dumps(user_info) GREmore = dict() sub_list = list() for sub in Stasub.get_sub(g.db, user_id): sub_dict = dict() sub_dict["id"] = sub.sub_id sub_dict["grade"] = sub.grade sub_list.append(sub_dict) GREmore["sub"] = sub_list GREmore["V"] = score.GRE_v GREmore["Q"] = score.GRE_q GREmore["AW"] = score.GRE_aw GREmore["total"] = user.GRE if GREmore.get("V") != 0: user_info["GREmore"] = GREmore TOEFLmore = dict() TOEFLmore["R"] = score.TOEFL_r TOEFLmore["L"] = score.TOEFL_l TOEFLmore["S"] = score.TOEFL_s TOEFLmore["W"] = score.TOEFL_w TOEFLmore["total"] = user.TOEFL if TOEFLmore.get("R") != 0: user_info["TOEFLmore"] = TOEFLmore SATmore = dict() SATmore["sub"] = sub_list SATmore["CR"] = score.SAT_cr SATmore["W"] = score.SAT_w SATmore["M"] = score.SAT_m SATmore["total"] = user.SAT if SATmore.get("M") != 0: user_info["SATmore"] = SATmore IELTSmore = dict() IELTSmore["R"] = score.IELTS_r IELTSmore["L"] = score.IELTS_l IELTSmore["S"] = score.IELTS_s IELTSmore["W"] = score.IELTS_w IELTSmore["total"] = user.IELTS if IELTSmore.get("R") != 0: user_info["IELTSmore"] = IELTSmore GMATmore = dict() GMATmore["V"] = score.GMAT_v GMATmore["Q"] = score.GMAT_q GMATmore["AW"] = score.GMAT_aw GMATmore["IR"] = score.GMAT_ir GMATmore["total"] = user.GMAT if GMATmore.get("V") != 0: user_info["GMATmore"] = GMATmore return json.dumps(user_info) return jsonify(status="success")
def get_user_detail_info(): if request.method == "GET": student_id = request.args.get("studentid", 0, int) student_info = dict() offers = list() login_user_id = session.get("user_id") user_info = User.get_user_info(g.db, student_id) if login_user_id is None: login_user_id = -1 for row in Offer.get_offer_student_info(g.db, student_id): offer_info = dict() for row_un in University.get_university_info( g.db, str(row.university_id)): offer_info["universityname"] = row_un.name offer_info["universityid"] = row_un.id offer_info["logo"] = get_university_logo(row_un.name) offer_info["twodimcode"] = row.wechat for row_ma in Major.get_major_info_by_id(g.db, row.major_id): offer_info["majorname"] = row_ma.name offer_info["grade"] = row.grade offer_info["offertype"] = row.offer_type if row.scholarship is not None: offer_info["scholarship"] = \ str(row.scholarship) + row.scholarship_type # offer_info["scholarship"] = None offers.append(offer_info) student_info["offers"] = offers compares = [] compares_info = {} for row_co in Compare.get_compare_user_id(g.db, student_id): compares_info["compareid"] = row_co.id compareslist = list() compares_un = {} for row_ci in CompareInfo.get_compare_info(g.db, row_co.id): for row_un in University.get_university_info( g.db, row_ci.university_id): compares_un["universityname"] = row_un.name compares_un["universityid"] = row_un.id compares_un["logo"] = row_un.schoollogo for row_ma in CompareInfo.get_compare_info( g.db, row_ci.major_id): compares_un["majorname"] = row_ma.name compares_un["supportnum"] = row_ci.supportnum compares_un["offernum"] = Offer.get_offer_num( g.db, row_ci.university_id) compareslist.append(compares_un) compares_un = {} compares_info["comparelist"] = compareslist compares.append(compares_info) student_info["compares"] = compares user = User.get_user_info(g.db, student_id) student_info["fannum"] = UserFollow.get_follow_count_user( g.db, student_id) if user is None: student_info["description"] = "" student_info["bginf"] = "" else: student_info["description"] = user.description student_info["bginf"] = user.bginf if int(login_user_id) == int(student_id): student_info["self"] = "true" student_info["phone"] = user.phone student_info["email"] = user.email else: student_info["self"] = "false" student_info["phone"] = "" student_info["email"] = "" message = list() for row_meg in Message.get_message_user(g.db, student_id): message_dict = dict() message_dict["messageid"] = row_meg.id user_id = row_meg.user_id user = User.get_user_info(g.db, user_id) if user is None: message.append(message_dict) else: message_dict["pic"] = user.pic message_dict["name"] = user.username message_dict["studentid"] = user_id message_dict["content"] = row_meg.message message_dict["time"] = get_timestamp(row_meg.create_time) message.append(message_dict) student_info["messages"] = message u"""这个位置的关注状态逻辑有点奇葩,以后要多注意""" follow_status = UserFollow.get_follow_to_user(g.db, login_user_id, student_id) if follow_status is not None: student_info["followed"] = "true" else: student_info["followed"] = "false" follows_list = list() for row_follow in UserFollow.get_follow_id(g.db, student_id): follows = dict() follow_user_id = row_follow.follow_user_id user = User.get_user_info(g.db, follow_user_id) if user is None: follows_list.append(follows) else: follows["name"] = user.username follows["pic"] = user.pic follows["studentid"] = follow_user_id follows_list.append(follows) student_info["follows"] = follows_list student_info["status"] = "success" score = Score.get_user_score(g.db, student_id) coupons = dict() print user_info.account, user.active, if user_info.active == 1 and (user_info.account != 0 and user_info.account is not None): coupons["code"] = user_info.coupon coupons["account"] = user_info.account student_info["coupons"] = coupons elif user_info.active == 2 and (user_info.account != 0 and user_info.account is not None): coupons["code"] = None coupons["account"] = user_info.account student_info["coupons"] = coupons elif user_info.active == 1 and (user_info.account != 0 and user_info.account is not None ) and user_info.coupon is None: coupons["code"] = "not_coupons" coupons["account"] = user_info.account student_info["coupons"] = coupons if score is None: return jsonify(student_info) sub_list = list() for row in Stasub.get_sub(g.db, student_id): sub = dict() sub["id"] = row.id sub["grade"] = row.grade sub_list.append(sub) GREmore = dict() GREmore["sub"] = sub_list GREmore["V"] = score.GRE_v GREmore["Q"] = score.GRE_q GREmore["AW"] = score.GRE_aw GREmore["total"] = user_info.GRE if GREmore.get("total") not in (0, None): student_info["GREmore"] = GREmore IELTSmore = dict() IELTSmore["R"] = score.IELTS_r IELTSmore["L"] = score.IELTS_l IELTSmore["S"] = score.IELTS_s IELTSmore["W"] = score.IELTS_w IELTSmore["total"] = user_info.IELTS if IELTSmore.get("total") not in (0, None): student_info["IELTSmore"] = IELTSmore TOEFLmore = dict() TOEFLmore["R"] = score.TOEFL_r TOEFLmore["L"] = score.TOEFL_l TOEFLmore["S"] = score.TOEFL_s TOEFLmore["W"] = score.TOEFL_w TOEFLmore["total"] = user_info.TOEFL if TOEFLmore.get("total") not in (0, None): student_info["TOEFLmore"] = TOEFLmore SATmore = dict() SATmore["CR"] = score.SAT_cr SATmore["W"] = score.SAT_w SATmore["M"] = score.SAT_m SATmore["total"] = user_info.SAT if SATmore.get("total") not in (0, None): student_info["SATmore"] = SATmore GMATmore = dict() GMATmore["V"] = score.GMAT_v GMATmore["Q"] = score.GMAT_q GMATmore["AW"] = score.GMAT_aw GMATmore["IR"] = score.GMAT_ir GMATmore["total"] = user_info.GMAT if GMATmore.get("V") not in (0, None): student_info["GMATmore"] = GMATmore return json.dumps(student_info)
def get_user_base_info(): u"""获取个人信息,用来更细资料""" if request.method == "GET": user_id = session.get("user_id") user = User.get_user_info(g.db, user_id) user_info = dict() user_info["status"] = "success" data = dict() data["type"] = str(user.type) data["bginf"] = user.bginf user_info["data"] = data score = Score.get_user_score(g.db, user_id) if score is None: return jsonify(user_info) GREmore = dict() # GREmore["sub"] = list() sub_list = list() data["GREmore"] = None data["TOEFLmore"] = None data["SATmore"] = None data["IELTSmore"] = None data["GMATmore"] = None for sub in Stasub.get_sub(g.db, user_id): sub_dict = dict() sub_dict["id"] = sub.sub_id sub_dict["grade"] = sub.grade sub_list.append(sub_dict) GREmore["sub"] = sub_list GREmore["V"] = score.GRE_v GREmore["Q"] = score.GRE_q GREmore["AW"] = score.GRE_aw GREmore["total"] = user.GRE if GREmore.get("V") != 0: data["GREmore"] = GREmore TOEFLmore = dict() TOEFLmore["R"] = score.TOEFL_r TOEFLmore["L"] = score.TOEFL_l TOEFLmore["S"] = score.TOEFL_s TOEFLmore["W"] = score.TOEFL_w TOEFLmore["total"] = user.TOEFL if TOEFLmore.get("W") != 0: data["TOEFLmore"] = TOEFLmore SATmore = dict() SATmore["sub"] = sub_list SATmore["CR"] = score.SAT_cr SATmore["W"] = score.SAT_w SATmore["M"] = score.SAT_m SATmore["total"] = user.SAT if SATmore.get("CR") != 0: data["SATmore"] = SATmore IELTSmore = dict() IELTSmore["R"] = score.IELTS_r IELTSmore["L"] = score.IELTS_l IELTSmore["S"] = score.IELTS_s IELTSmore["W"] = score.IELTS_w IELTSmore["total"] = user.IELTS if IELTSmore.get("R") != 0: data["IELTSmore"] = IELTSmore GMATmore = dict() GMATmore["V"] = score.GMAT_v GMATmore["Q"] = score.GMAT_q GMATmore["AW"] = score.GMAT_aw GMATmore["IR"] = score.GMAT_ir GMATmore["total"] = user.GMAT if GMATmore.get("V") != 0: data["GMATmore"] = GMATmore return jsonify(user_info) return jsonify(status="false")