Exemple #1
0
def get_compare():
    if request.method == "GET":
        compareid = request.args.get("compareid")
        compare = {}
        compare_info = {}
        comparelist = []
        com = Compare.get_compare(g.db, int(compareid))
        compare["compareid"] = com.id
        compare["description"] = com.description
        compare["date"] = get_timestamp(com.create_time)
        compare["studentid"] = com.user_id
        for row in CompareInfo.get_compare_info(g.db, compareid):
            compare_info["universityid"] = row.university_id
            compare_info["major_id"] = row.major_id
            compare_info["supportnum"] = row.supportnum
            for university in University.get_university_info(g.db, university_id=row.university_id):
                compare_info["universityname"] = university.name
                compare_info["logo"] = get_university_logo(university.name)
            for major in Major.get_major_info(g.db,
                                              university_id=compare_info[
                                                  "universityid"],
                                              major_id=compare_info[
                                                  "major_id"]):
                compare_info["majorname"] = major.name
            compare_info["offernum"] = Offer.get_offer_num(g.db, row.university_id)
            comparelist.append(compare_info)

            compare_info = {}
        compare["comparelist"] = comparelist
        compare["status"] = "success"
        return json.dumps(compare)
def term_main(root_absdir,pre_imgdir,old_imgdir_prefix):
    utils.move_imgdir_to_oldimgdir(root_absdir,pre_imgdir,old_imgdir_prefix)
    timestamp=utils.get_timestamp()
    msg_term="Script was teriminated at {date}".format(date=timestamp)
    print(msg_term)
def term_sub_proc(root_absdir,pre_imgdir,old_imgdir_prefix):
    utils.move_imgdir_to_oldimgdir(root_absdir,pre_imgdir,old_imgdir_prefix)
    timestamp=utils.get_timestamp()
    msg_term="Subprocess for downloading images was teriminated at {date}".format(date=timestamp)
    print(msg_term)
Exemple #4
0
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)