Exemplo n.º 1
0
def search():
    province = request.values.get('prov5')
    city = request.values.get('city5')
    district = request.values.get('area5')
    price = request.values.get('price')
    print(province)
    print(city)
    print(district)
    print(price)

    if province == '-1' or city == '-1' or district == '-1':
        return redirect_with_msg('/mainpage/', u'请选择省,市,区进行搜索', 'research')

    house_list = House.query.filter_by(province=province, city=city, district=district).all()
    if price is not None:
        price = int(price)
        house_newlist = []
        for house in house_list:
            if price != 10000 and price - 100 < house.price <= price:
                print(house.price)
                house_newlist.append(house)
            elif price == 10000 and price > 500:
                print(house.price)
                house_newlist.append(house)
        pager_obj = Pagination(request.args.get("page", 1), len(house_newlist), request.path, request.args,
                               per_page_count=6)
        index_list = house_newlist[pager_obj.start:pager_obj.end]
    else:
        pager_obj = Pagination(request.args.get("page", 1), len(house_list), request.path, request.args,
                               per_page_count=6)
        index_list = house_list[pager_obj.start:pager_obj.end]

    html = pager_obj.page_html()
    length = len(index_list)
    return render_template("mainpage.html", house=index_list, html=html, length=length)
Exemplo n.º 2
0
def history():
    # 先得到目前的用户然后从数据库中查询这个用户的所有订单
    # 得到这个用户的作为买家的所有订单
    now_compare = datetime.now().date()
    user = current_user
    result_renter = []
    renter_list = Order.query.filter_by(renter=user.username).all()
    for item in renter_list:
        one = {}
        one_house = House.query.filter_by(id=item.house_id).first()
        one['order'] = item
        one['house'] = one_house
        if now_compare < item.start_time and item.status == 1:
            one['cancel'] = 1
        else:
            one['cancel'] = 0
        print(one)
        result_renter.append(one)
    # 返回的是List类型

    pager_obj = Pagination(request.args.get("page", 1), len(result_renter), request.path, request.args, per_page_count=7)
    renter_list = result_renter[pager_obj.start:pager_obj.end]
    html = pager_obj.page_html()

    return render_template('renting.html', result_renter=renter_list, html=html)
Exemplo n.º 3
0
def myhouse():
    '''根据当前用户查询房屋表,得到这个用户的房屋信息返回给前端'''
    user = current_user
    house_list = House.query.filter_by(username=user.username).all()
    pager_obj = Pagination(request.args.get("page", 1), len(house_list), request.path, request.args, per_page_count=7)
    index_list = house_list[pager_obj.start:pager_obj.end]
    html = pager_obj.page_html()
    return render_template("myhouse.html", house=index_list, html=html)
Exemplo n.º 4
0
def adminprofile():
    msg = ''
    for m in get_flashed_messages(with_categories=False, category_filter=['message']):
        msg += m
    uncheck_list = House.query.filter_by(status=0).all()

    pager_obj = Pagination(request.args.get("page", 1), len(uncheck_list), request.path, request.args,
                           per_page_count=7)
    house_list = uncheck_list[pager_obj.start:pager_obj.end]
    html = pager_obj.page_html()

    return render_template('admin.html', house=house_list, msg=msg, html=html)
Exemplo n.º 5
0
def mainpage():
    msg = ''
    for m in get_flashed_messages(with_categories=False, category_filter=['research']):
        msg += m
    house_list = House.query.filter_by(status=1).all()
    pager_obj = Pagination(request.args.get("page", 1), len(house_list), request.path, request.args, per_page_count=6)
    print(request.path)
    print(request.args)
    index_list = house_list[pager_obj.start:pager_obj.end]
    html = pager_obj.page_html()
    length = len(index_list)
    return render_template("mainpage.html", house=index_list, html=html, msg=msg, length=length)
Exemplo n.º 6
0
def search_index():
    print("serach_index")
    msg = ''
    for m in get_flashed_messages(with_categories=False, category_filter=['research']):
        msg += m

    search_index = request.values.get('search').strip()
    search_list = House.query.filter(or_(House.address.like("%"+search_index+"%") if search_index is not None else "",
                                            House.house_name.like("%"+search_index+"%") if search_index is not None else "")).all()

    pager_obj = Pagination(request.args.get("page", 1), len(search_list), request.path, request.args, per_page_count=6)
    print(request.path)
    print(request.args)
    index_list = search_list[pager_obj.start:pager_obj.end]
    html = pager_obj.page_html()
    length = len(index_list)
    return render_template("mainpage.html", house=index_list, html=html, msg=msg, length=length)
Exemplo n.º 7
0
def operating():
    # 得到订单
    username = current_user.username
    result_seller = []
    seller_list = Order.query.filter_by(seller=username, status=1).all()
    seller_list_two = Order.query.filter_by(seller=username, status=3).all()
    for item in seller_list:
        one = {}
        one_house = House.query.filter_by(id=item.house_id).first()
        one['order'] = item
        one['house'] = one_house
        result_seller.append(one)
    for item in seller_list_two:
        one = {}
        one_house = House.query.filter_by(id=item.house_id).first()
        one['order'] = item
        one['house'] = one_house
        result_seller.append(one)

    pager_obj = Pagination(request.args.get("page", 1), len(result_seller), request.path, request.args, per_page_count=7)
    seller_list = result_seller[pager_obj.start:pager_obj.end]
    html = pager_obj.page_html()

    return render_template('operating.html', result_seller=seller_list, html=html)