Exemplo n.º 1
0
def postregister():
    if (request.method == 'POST'):
        data = request.form
        username = data['agent_username']
        password = data['agent_pw']

        print(data)
        MySQL.register(cursor, db, username, password)
        flash("注册成功")
        time.sleep(2)
    return redirect(url_for('login'))
Exemplo n.º 2
0
def view_order():
    agent_username = current_user.id
    result, flag = MySQL.agent_order(cursor, agent_username)
    if flag:
        return render_template('agent_order.html', result=result)
    else:
        return "wrong"
Exemplo n.º 3
0
def passguest():
    guest_username = request.args.get('guest_username')
    flag = MySQL.admin_pass_guest(db, cursor, guest_username)
    if flag:
        return redirect(url_for('admin.orderlist'))
    else:
        return "wrong"
Exemplo n.º 4
0
def agentlist():
    result, flag = MySQL.admin_agentlist(cursor)
    print(str(result))
    if flag:
        return render_template('admin_agentlist.html', result=result)
    else:
        return "wrong"
Exemplo n.º 5
0
def feature():
    guest_username = current_user.id
    flag, result = MySQL.guest_feature(cursor, guest_username)
    if flag:
        return render_template('guest_feature.html', result=result)
    else:
        return "wrong"
Exemplo n.º 6
0
def postregister():
    if (request.method == 'POST'):
        data = request.form
        guest_username = data['guest_username']
        guest_pw = data['guest_pw']
        guest_name = data['guest_name']
        # birthday = data['birthday']
        gender = data['gender']
        job = data['job']
        wechat = data['wechat']
        guest_phone = data['guest_phone']
        graduate_school = data['graduate_school']
        major = data['major']
        data = data.to_dict()
        l = data.keys()
        value = ""
        for key in l:
            if key in [
                    'read', 'music', 'movie', 'talkshow', 'fashion', 'weibo',
                    'zhihu', 'food', 'healthy', 'paint', 'drama', 'game'
            ]:
                value = value + str(data[key]) + " "
        flag = MySQL.guest_register(cursor, db, guest_username, guest_pw,
                                    gender, guest_name, job, wechat,
                                    guest_phone, graduate_school, major, value)
        if flag == 1:
            flash("已提交申请,还需管理员审核")
        else:
            flash("注册失败,请重新注册!")
    return redirect(url_for('guest.login'))  #需要更改!!!
Exemplo n.º 7
0
def view_order():
    guest_username = current_user.id
    result, flag = MySQL.guest_order(cursor, guest_username)
    if flag:
        return render_template('guest_orderlist.html', result=result)
    else:
        return "wrong"
Exemplo n.º 8
0
def admin_guest_feature():
    if request.method == 'GET':
        guest_username = request.args.get('guest_username')
        flag, result = MySQL.guest_feature(cursor, guest_username)
        if flag:
            return render_template('admin_guest_feature.html', result=result)
        else:
            return "wrong"
Exemplo n.º 9
0
def modify():
    if request.method == 'GET':
        apt_id = request.args.get('apt_id')
        t = apt_id
        result, flag = MySQL.agent_modify_view(cursor, apt_id)
        if flag:
            return render_template('agent_modify.html',
                                   result=result,
                                   apt_id=apt_id)
        return "success"
    elif request.method == 'POST':
        data = request.form
        apt_id = data['apt_id']
        apt_name = data['apt_name']
        bathroom_count = int(data['bathroom_count'])
        bedroom_count = int(data['bedroom_count'])
        price = data['price']
        direction = data['direction']
        building_name = data['building_name']
        place = data['place']
        building_manager = data['building_manager']
        building_phone = data['building_phone']
        other_details = data['other_details']
        pic_url = data['pic_url']
        room_area = data['room_area']
        transport = data['transport']
        max_people_count = int(data['max_people_number'])
        full_place = place.split('/')
        # province = full_place[0]
        # city = full_place[1]
        district = full_place[2]
        agent_username = current_user.id
        agent_id = MySQL.find_agent_id(cursor, agent_username)

        flag = MySQL.agent_modify(db, cursor, agent_id, apt_name,
                                  bathroom_count, bedroom_count, room_area,
                                  transport, max_people_count, pic_url, price,
                                  direction, building_name, district,
                                  building_manager, building_phone,
                                  other_details, apt_id)
        if flag:
            return "success"
        else:
            return str(data)
Exemplo n.º 10
0
def modify():
    if request.method == 'GET':
        guest_username = request.args.get('guest_username')
        flag, result = MySQL.guest_feature(cursor, guest_username)
        if flag:
            return render_template('guest_modify.html', result=result)
        else:
            return "wrong"
    if request.method == 'POST':
        data = request.form
        guest_username = data['guest_username']
        guest_pw = data['guest_pw']
        guest_name = data['guest_name']
        # birthday = data['birthday']
        gender = data['gender']
        job = data['job']
        wechat = data['wechat']
        guest_phone = data['guest_phone']
        graduate_school = data['graduate_school']
        major = data['major']
        data = data.to_dict()
        l = data.keys()
        value = ""
        for key in l:
            if key in [
                    'read', 'music', 'movie', 'talkshow', 'fashion', 'weibo',
                    'zhihu', 'food', 'healthy', 'paint', 'drama', 'game'
            ]:
                value = value + str(data[key]) + " "
        flag = MySQL.guest_modify(cursor, db, guest_username, guest_pw, gender,
                                  guest_name, job, wechat, guest_phone,
                                  graduate_school, major, value)
        if flag:
            flash("修改成功!")
            time.sleep(2)
            return redirect(url_for('guest.feature'))
        else:
            flash("修改失败!")
            time.sleep(2)
            return redirect(url_for('index'))
Exemplo n.º 11
0
def postlogin():
    if request.method == 'POST':
        data = request.form
        username = str(data['username'])
        password = data['password']
        res = MySQL.guest_login(cursor, username, password)
        if (res):
            curr_user = User(username)
            login_user(curr_user)
            print(current_user.id)
            return redirect(url_for('index'))

        else:
            return "not"  #用户注册失败,需要修改!!!
Exemplo n.º 12
0
def examine():
    results = MySQL.query_apply(cursor)
    return str(results)
Exemplo n.º 13
0
def hello_world():
    data = MySQL.VERSION(cursor)
    return 'Hello World!' + str(data)
Exemplo n.º 14
0
def guestlist():
    result, flag = MySQL.admin_guestlist(cursor)
    if flag:
        return render_template('admin_guestlist.html', result=result)
    else:
        return "wrong"