Exemple #1
0
def prelic():
    form = SechandhouseFilterForm().validate_for_api()

    prelic = form.presale_license_number.data
    sechandhouses = Sechandhouse.query.filter(
        Sechandhouse.presale_license_number == prelic)
    total = len(sechandhouses.all())
    # 分页
    page = form.page.data
    per_page = form.per_page.data
    sechandhouses = PageChoose.PageChoose(page=page,
                                          per_page=per_page,
                                          data=sechandhouses)

    sechandhouses = \
        [SechandhouseViewModel.secviewmodel(sechandhouse) for sechandhouse in sechandhouses]

    return SuccessViewModel.redict_page(dicts=sechandhouses,
                                        page=page,
                                        total=total)
Exemple #2
0
def prelic():
    form = SingleroomFilterForm().validate_for_api()
    ad = form.order_ad.data
    present = form.order_basis.data

    prelic = form.presale_license_number.data
    singlerooms = Singleroom.query.filter(
        Singleroom.presale_license_number == prelic
        # ,
        # Singleroom.state != '非销售房产'
    ).order_by(singleroom_order_ad.Singleroom_Order_Ad(ad=ad, present=present))

    total = len(singlerooms.all())
    # 分页
    page = form.page.data
    per_page = form.per_page.data
    singlerooms = PageChoose.PageChoose(page=page, per_page=per_page, data=singlerooms)

    singlerooms = [SingleroomViewModel.singleroomviewmodel(singleroom) for singleroom in singlerooms]
    # 总价无法计算是因为对象返回时list,未通过其他视图层转化成字典对象
    return SuccessViewModel.redict_page(dicts=singlerooms, page=page, total=total)
Exemple #3
0
def filter():
    form = FilterForm().validate_for_api()
    ad = form.order_ad.data
    present = form.order_basis.data
    # 多条件筛选
    building_search = '%' + form.building_search._value().replace(" ",
                                                                  "") + '%'
    #区域多选
    region_choose = \
        MultiSelect.MultiSelect(string=form.hist_region_choose.data, dic=HIST_REGION)

    histsups = Histsup.query.filter(
        and_(
            Histsup.opening_date >= DateIsEmpty.dateisempty(
                form.opening_date_min),
            Histsup.opening_date <= isempty.IsEmpty(form.opening_date_max),
            Histsup.huxing_area >= isempty.IsEmpty(form.huxing_area_min),
            Histsup.huxing_area <= isempty.IsEmpty(form.huxing_area_max),
            Histsup.houses_average >= isempty.IsEmpty(form.houses_average_min),
            Histsup.houses_average <= isempty.IsEmpty(form.houses_average_max),
            Histsup.commercial_average >= isempty.IsEmpty(
                form.commercial_average_min), Histsup.commercial_average <=
            isempty.IsEmpty(form.commercial_average_max),
            or_(Histsup.building_promotion_name.like(building_search),
                Histsup.building_name.like(building_search),
                Histsup.presale_license_number.like(building_search),
                Histsup.building_address.like(building_search)),
            or_(*[Histsup.region.like(r) for r in region_choose]))).order_by(
                histsup_order_ad.Histsup_Order_Ad(ad=ad, present=present))

    total = len(histsups.all())
    # 如果有page传入则分页,其他不分页
    page = form.page.data
    per_page = form.per_page.data
    histsups = PageChoose.PageChoose(page=page,
                                     per_page=per_page,
                                     data=histsups)

    # 视图层转化
    histsups = [
        HistsupViewModel.re_data(histsup,
                                 VIEW_TYPE[form.view_type_choose.data])
        for histsup in histsups
    ]

    # 添加levels字段
    hisrange = [
        histsup[VIEW_TYPE[form.view_type_choose.data]] for histsup in histsups
    ]
    level = form.data_level.data
    for histsup in histsups:
        for i in range(level):
            if histsup[VIEW_TYPE[form.view_type_choose.data]] <= \
                    DataLayer.DataLayer(lists=hisrange, degree=i+1, level=level):
                histsup['levels'] = i + 1
                break
    # 显示状态码
    if len(histsups) > 0:
        for histsup in histsups:
            histsup["display_code"] = 0
        histsups[0]["display_code"] = 1

    return SuccessViewModel.redict_page(histsups, page=page, total=total)
Exemple #4
0
def filter():
    form = LandFilterForm().validate_for_api()
    ad = form.order_ad.data
    present = form.order_basis.data
    land_search = '%' + form.land_search._value().replace(" ", "") + '%'

    # 区域,土地用途,地块状态多选
    region_choose = \
        MultiSelect.MultiSelect(string=form.land_region_choose.data, dic=LAND_REGION)
    land_usage_choose = \
        MultiSelect.MultiSelect(string=form.land_usage_type_choose.data, dic=LAND_USAGE_TYPE)
    block_status_choose = \
        MultiSelect.MultiSelect(string=form.land_block_status_choose.data, dic=LAND_BLOCK_STATUS)

    lands = Land.query.filter(
        and_(
            Land.listing_start_date >= DateIsEmpty.dateisempty(
                form.listing_start_date_min), Land.listing_start_date <=
            isempty.IsEmpty(form.listing_start_date_max),
            Land.total_land_area >= isempty.IsEmpty(form.total_land_area_min),
            Land.total_land_area <= isempty.IsEmpty(form.total_land_area_max),
            Land.price >= isempty.IsEmpty(form.price_min),
            Land.price <= isempty.IsEmpty(form.price_max),
            Land.deal_date > isempty.IsEmpty(form.deal_date_min)
            if form.land_view_type_choose.data == '2' else
            Land.deal_date >= isempty.IsEmpty(form.deal_date_min),
            Land.deal_date <= isempty.IsEmpty(form.deal_date_max),
            Land.deal_price >= isempty.IsEmpty(form.deal_price_min),
            Land.deal_price <= isempty.IsEmpty(form.deal_price_max),
            or_(Land.plotnum.like(land_search),
                Land.block_name.like(land_search),
                Land.block_location.like(land_search),
                Land.competitive_unit.like(land_search),
                Land.deal_date.like(land_search)),
            or_(*[Land.region.like(r) for r in region_choose]),
            or_(*[Land.land_usage.like(l) for l in land_usage_choose]),
            or_(*[Land.block_status.like(b)
                  for b in block_status_choose]))).order_by(
                      land_order_ad.Land_Order_Ad(ad=ad, present=present))

    total = len(lands.all())
    # 如果有page传入则分页,其他不分页
    page = form.page.data
    per_page = form.per_page.data
    lands = PageChoose.PageChoose(page=page, per_page=per_page, data=lands)

    # 视图层转化
    lands = [
        LandViewModel.landviewmodel(
            land, LAND_VIEW_TYPE[form.land_view_type_choose.data])
        for land in lands
    ]

    # 添加levels字段
    landrange = [
        land[LAND_VIEW_TYPE[form.land_view_type_choose.data]] for land in lands
    ]
    level = int(form.data_level.data)
    for land in lands:
        for i in range(level):
            if land[LAND_VIEW_TYPE[form.land_view_type_choose.data]] <= \
                    DataLayer.DataLayer(lists=landrange, degree=i + 1, level=level):
                land['levels'] = i + 1
                break
    # 显示状态码
    if len(lands) > 0:
        for land in lands:
            land["display_code"] = 0
        lands[0]["display_code"] = 1

    return SuccessViewModel.redict_page(dicts=lands, page=page, total=total)