Exemplo n.º 1
0
def search_second_category(request):
    channel = request.GET.get("channel")
    categories = CmsCategoryItem.objects.filter(
        cmsviewcategoryitem__channel_id=channel)
    result = []
    for category in categories:
        scene = get_scene_name(category.scene_id)
        status_str, status_int = get_check_status_str("CmsCategoryItem",
                                                      category.id)
        item = {
            "group": [
                scene, category.sort, category.service.name, category.name,
                category.name_color, status_str, status_int, category.id
            ],
            "members": []
        }
        members = CmsCategoryItembean.objects.filter(
            cmscategoryitemitembean__category_item=category)
        for member in members:
            photoUrl, photo_str, search_show, s_key, search_category, home, weibo = analyze_shop_content(
                member)
            status_str, status_int = get_check_status_str(
                "CmsCategoryItembean", member.id)
            item["members"].append([
                member.item_id, photoUrl, member.name, member.sort, photo_str,
                search_show, search_category, s_key, member.search_sort,
                get_valid_time(member.valid_time),
                get_city_str(member.city), status_str, status_int, member.id
            ])
        item["members"].sort(key=lambda o: (o[3]))
        result.append(item)
    filter_none(result)
    result.sort(key=lambda o: (o["group"][0], o["group"][1]))
    return HttpResponse(json.dumps(result))
Exemplo n.º 2
0
def search_ads(request):
    channel = request.GET.get("channel")
    ads = CmsAds.objects.filter(cmsviewad__channel__id=channel)
    result = []
    for ad in ads:
        status_str, status_int = get_check_status_str("CmsAds", ad.id)
        item = {
            "ad": [
                get_scene_name(ad.scene_id), ad.location,
                get_2array_value(ad_size, ad.size),
                get_2array_value(ad_type, ad.type), status_str, status_int,
                ad.id
            ],
            "beans": []
        }
        beans = CmsAdbeans.objects.filter(cmsadsbeans__ad=ad)
        for bean in beans:
            status_str, status_int = get_check_status_str(
                "CmsAdbeans", bean.id)
            item["beans"].append([
                bean.img_url, bean.name, bean.location, bean.action_id,
                get_valid_time(bean.valid_time),
                get_city_str(bean.city), bean.phone_type, status_str,
                status_int, bean.id
            ])
        result.append(item)
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 3
0
def handle_valid_time_city(objs, index_time=None, index_city=None):
    result = []
    for obj in objs:
        item = list(obj)
        if index_time is not None:
            item[index_time] = get_valid_time(item[index_time])
        if index_city is not None:
            item[index_city] = get_city_str(item[index_city])
        result.append(item)
    return result
Exemplo n.º 4
0
Arquivo: likes.py Projeto: cash2one/pt
def search_likes(request):
    channel = request.GET.get("channel")
    groups = CmsLikes.objects.filter(cmsviewlike__channel__id=channel)
    result = []
    for group in groups:
        group_scene = get_scene_name(group.scene_id)
        status_str, status_int = get_check_status_str("CmsLikes", group.id)
        item = {
            "group": [
                group_scene, group.title, group.title_style, group.desc,
                group.desc_style, status_str, status_int, group.id
            ],
            "members": []
        }
        #服务
        services = CmsServices.objects.filter(cmslikesservices__like=group)
        for service in services:
            status_str, status_int = get_check_status_str(
                "CmsServices", service.id)
            item["members"].append([
                service.small_icon_url, service.name, service.name_style,
                service.desc, service.desc_style, service.location,
                service.dot_info, service.action_id, "服务",
                get_valid_time(service.valid_time),
                get_city_str(service.city), status_str, 1, status_int,
                service.id
            ])
        #商品
        goods = CmsGoods.objects.filter(cmslikesgoods__like=group)
        for good in goods:
            status_str, status_int = get_check_status_str("CmsGoods", good.id)
            item["members"].append([
                good.small_icon_url, good.name, good.name_style, good.desc,
                good.desc_style, good.location, good.dot_info, good.action_id,
                "商品",
                get_valid_time(good.valid_time),
                get_city_str(good.city), status_str, 0, status_int, good.id
            ])
        result.append(item)
        item["members"].sort(key=lambda o: (o[8], o[5]))
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 5
0
def search_coupons(request):
    channel_id = request.GET.get('channel')
    objs = CmsCoupon.objects.filter(cmsviewcoupon__channel_id=channel_id)
    result = []
    for obj in objs:
        scene_name = get_scene_name(obj.scene_id)
        status_str, status_int = get_check_status_str("CmsCoupon", obj.id)
        result.append([
            scene_name, obj.location, obj.name, obj.url,
            get_valid_time(obj.valid_time),
            get_city_str(obj.city), status_str, status_int, obj.id
        ])
    result.sort(key=lambda o: (o[0], o[1]))
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 6
0
def search_activities(request):
    channel_id = request.GET.get('channel')
    objs = CmsActivities.objects.filter(cmsviewactivity__channel_id=channel_id)
    result = []
    for obj in objs:
        status_str, status_int = get_check_status_str("CmsActivities", obj.id)
        result.append([
            get_scene_name(obj.scene_id), obj.location, obj.url,
            get_2array_value(open_type, obj.open_type),
            get_valid_time(obj.valid_time),
            get_city_str(obj.city), status_str, status_int, obj.id
        ])
    result.sort(key=lambda o: (o[0], o[1]))
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 7
0
def search_goods(request):
    per_page = request.GET.get("per_page")
    if not per_page:
        per_page = MainConst.PER_PAGE
    cur_page = request.GET.get("cur_page")
    if not cur_page:
        cur_page = 1
    key = request.GET.get("key")
    objs = CmsGoods.objects.filter(parent_id=-1).order_by("-sort")
    goods = []
    all_category = CmsNaviCategory.objects.all()
    for obj in objs:
        new_category = ""
        new_second_category = ""
        if obj.new_category:
            try:
                for cate in all_category:
                    if obj.new_category == cate.id:
                        new_category = cate.name
                        break
            except:
                log.error(
                    str(obj.new_second_category) +
                    " is not query by cms_navi_category")
        if obj.new_second_category:
            try:
                for sec_cate in all_category:
                    if obj.new_second_category == sec_cate.id:
                        new_second_category = sec_cate.name
            except:
                log.error(
                    str(obj.new_second_category) +
                    " is not query by cms_navi_category")
        status_str, status_int = get_check_status_str("CmsGoods", obj.id)
        goods.append([
            new_category, new_second_category, obj.name, obj.small_icon_url,
            obj.icon_url, obj.goods_id, obj.cp_name, obj.desc,
            obj.search_keyword,
            get_valid_time(obj.valid_time),
            get_city_str(obj.city), status_str, obj.is_support_cart,
            obj.min_version, obj.max_version, obj.recommend_icon,
            obj.recommend_reason, obj.sort, status_int, obj.id
        ])
    result = search_key(goods, key, [1, 10, 11])
    result, num_pages = get_table_paginator(result, per_page, cur_page)
    filter_none(result)
    return HttpResponse(json.dumps([list(result), num_pages]))
Exemplo n.º 8
0
def search(request):
    channel = request.GET.get("channel")
    activities = CmsActivityV37.objects.filter(
        cmsviewactivity37__channel__id=channel)
    result = []
    for activity in activities:
        goods = [o.title for o in activity.goods.all()]
        cps = [o.name for o in activity.cp.all()]
        status_str, status_int = "", 1
        item = [
            activity.name, activity.img, "<br/>".join(cps),
            "<br/>".join(goods),
            get_valid_time(activity.valid_time),
            get_city_str(activity.city), status_str, status_int, activity.id
        ]
        result.append(item)
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 9
0
def search_coupons(request):
    per_page = request.GET.get("per_page")
    if not per_page:
        per_page = MainConst.PER_PAGE
    cur_page = request.GET.get("cur_page")
    if not cur_page:
        cur_page = 1
    objs = CmsCoupon.objects.filter(parent_id=-1)
    coupons = []
    for obj in objs:
        status_str, status_int = get_check_status_str("CmsCoupon", obj.id)
        coupons.append([
            obj.name, obj.url, obj.coupon_id,
            get_valid_time(obj.valid_time),
            get_city_str(obj.city), status_str, status_int, obj.id
        ])
    key = request.GET.get("key")
    coupons_lst = search_key(coupons, key, [1, 6, 7])
    result, num_pages = get_table_paginator(coupons_lst, per_page, cur_page)
    return HttpResponse(json.dumps([list(result), num_pages]))
Exemplo n.º 10
0
def search_homepage_specialtopic(request):
    channel_id = request.GET.get('channel')
    objs = CmsViewHomepageTopic.objects.filter(channel_id=channel_id)
    result = []
    for obj in objs:
        topic = obj.topic
        scene_name = get_scene_name(topic.scene_id)
        status_str_topic, status_int_topic = get_check_status_str(
            "CmsSpecialTopic", topic.id)
        status_str_view, status_int_view = get_check_status_str(
            "CmsViewHomepageTopic", obj.id)
        result.append([
            scene_name, topic.image_url, topic.title, topic.title_color,
            topic.subtitle, topic.subtitle_color, topic.action_id,
            get_valid_time(topic.valid_time),
            get_city_str(topic.city), status_str_view,
            "%d/%d" % (status_int_topic, status_int_view), topic.id
        ])
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 11
0
def search_screen_ads(request):
    channel_id = request.GET.get('channel')
    objs = CmsScreenads.objects.filter(cmsviewscreenads__channel_id=channel_id)
    result = []
    for obj in objs:
        try:
            show_hold = "不限" if obj.show_hold == -1 else str(
                obj.show_hold) + "秒"
            status_str, status_int = get_check_status_str(
                "CmsScreenads", obj.id)
            result.append([
                obj.name, obj.img_url,
                get_2array_value(screen_ad_times, obj.show_times), show_hold,
                get_valid_time(obj.valid_time),
                get_city_str(obj.city), status_str, status_int, obj.id
            ])
        except:
            continue
    result.sort(key=lambda o: (o[0]))
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 12
0
def search_services(request):
    per_page = request.GET.get("per_page")
    if not per_page:
        per_page = MainConst.PER_PAGE
    cur_page = request.GET.get("cur_page")
    if not cur_page:
        cur_page = 1
    key = request.GET.get("key")
    objs = CmsServices.objects.filter(parent_id=0, type=0).order_by("-id")
    services = []
    for obj in objs:
        status_str, status_int = get_check_status_str("CmsServices", obj.id)
        services.append([
            obj.name, obj.small_icon_url, obj.icon_url, obj.desc, obj.memo,
            get_valid_time(obj.valid_time),
            get_city_str(obj.city), status_str, status_int, obj.id
        ])
    result = search_key(services, key, [1, 2, 8, 9])
    result, num_pages = get_table_paginator(result, per_page, cur_page)
    filter_none(result)
    return HttpResponse(json.dumps([list(result), num_pages]))
Exemplo n.º 13
0
def search_specialtopic(request):
    per_page = request.GET.get("per_page")
    if not per_page:
        per_page = MainConst.PER_PAGE
    cur_page = request.GET.get("cur_page")
    if not cur_page:
        cur_page = 1
    objs = CmsSpecialTopic.objects.filter()
    topics = []
    for obj in objs:
        status_str, status_int = get_check_status_str("CmsSpecialTopic",
                                                      obj.id)
        topics.append([
            obj.image_url, obj.title, obj.title_color, obj.subtitle,
            obj.subtitle_color, obj.action_id,
            get_valid_time(obj.valid_time),
            get_city_str(obj.city), status_str, status_int, obj.id
        ])
    key = request.GET.get("key")
    topics = search_key(topics, key, [0, 2, 4, 9, 10])
    result, num_pages = get_table_paginator(topics, per_page, cur_page)
    return HttpResponse(json.dumps([list(result), num_pages]))
Exemplo n.º 14
0
def search_activities(request):
    channel_id = request.GET.get('channel')
    objs = CmsNativeActivity.objects.filter(
        cmsviewnativeactivity__channel_id=channel_id)
    result = []
    for obj in objs:
        try:
            status_str, status_int = get_check_status_str(
                "CmsNativeActivity", obj.id)
            result.append([
                get_scene_name(obj.scene_id), obj.sort, obj.title,
                obj.title_color, obj.subtitle, obj.image_url,
                timestamp2str_space(obj.start_time),
                timestamp2str_space(obj.end_time), obj.action_id,
                get_valid_time(obj.valid_time),
                get_city_str(obj.city), status_str, status_int, obj.id
            ])
        except:
            continue
    result.sort(key=lambda o: (o[0], o[1]))
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 15
0
def search_foundpage_specialtopic(request):
    channel_id = request.GET.get('channel')
    objs = CmsViewFindTopic.objects.filter(channel_id=channel_id, is_deleted=0)
    result = []
    for obj in objs:
        topic = CmsSpecialTopic.objects.get(id=obj.topic_id)
        if obj.is_deleted == 0:
            scene_name = get_scene_name(topic.scene_id)
            is_top = "是" if obj.is_top else "否"
            status_str_topic, status_int_topic = get_check_status_str(
                "CmsSpecialTopic", topic.id)
            status_str_view, status_int_view = get_check_status_str(
                "CmsViewFindTopic", obj.id)
            result.append([
                scene_name, topic.image_url, topic.title, topic.title_color,
                topic.subtitle, topic.subtitle_color, topic.action_id, is_top,
                obj.mark_info,
                get_valid_time(topic.valid_time),
                get_city_str(topic.city), status_str_view,
                "%d/%d" % (status_int_topic, status_int_view), topic.id
            ])
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 16
0
def search_choiceness_categories(request):
    channel_id = request.GET.get('channel')
    objs = CmsChoicenessCategory.objects.filter(cmsviewchoicenesscategory__channel_id=channel_id)
    result = []
    for obj in objs:
        try:
            status_str, status_int = get_check_status_str("CmsChoicenessCategory", obj.id)
            result.append([
                obj.location,
                obj.category.name,
                obj.img_url,
                obj.img_url_d,
                obj.background_color,
                get_valid_time(obj.valid_time),
                get_city_str(obj.city),
                status_str,
                status_int,
                obj.id
            ])
        except:
            continue
    result.sort(key=lambda o: (o[0]))
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 17
0
def search_common_services(request):
    channel = request.GET.get("channel")
    items = []
    # 添加服务
    view_services = CmsViewService.objects.filter(open_type=0,
                                                  channel__id=channel)
    for view_service in view_services:
        try:
            status_str, status_int = get_check_status_str(
                "CmsServices", view_service.service_id)
            items.append([
                "功能服务", "服务", status_str,
                "%d/%d" % (status_int, status_int),
                CmsServices.objects.get(id=view_service.service_id)
            ])
        except:
            continue
    # 添加商品
    view_goods = CmsViewService.objects.filter(open_type=1,
                                               channel__id=channel)
    for view_good in view_goods:
        try:
            status_str, status_int = get_check_status_str(
                "CmsGoods", view_good.service_id)
            items.append([
                "功能服务", "商品", status_str,
                "%d/%d" % (status_int, status_int),
                CmsGoods.objects.get(id=view_good.service_id)
            ])
        except:
            continue
    # 添加一级分类
    view_first_categories = CmsViewService.objects.filter(open_type=3,
                                                          channel__id=channel)
    for view_first_category in view_first_categories:
        try:
            status_str_cate, status_int_cate = get_check_status_str(
                "CmsNaviCategory", view_first_category.service_id)
            status_str_view, status_int_view = get_check_status_str(
                "CmsViewService", view_first_category.id)
            items.append([
                "功能服务", "功能一级分类", status_str_view,
                "%d/%d" % (status_int_cate, status_int_view),
                CmsNaviCategory.objects.get(id=view_first_category.service_id)
            ])
        except:
            continue
    # 添加二级分类
    view_second_categories = CmsViewService.objects.filter(open_type=4,
                                                           channel__id=channel)
    for view_second_category in view_second_categories:
        try:
            status_str_cate, status_int_cate = get_check_status_str(
                "CmsNaviCategory", view_second_category.service_id)
            status_str_view, status_int_view = get_check_status_str(
                "CmsViewService", view_second_category.id)
            items.append([
                "功能服务", "功能二级分类", status_str_view,
                "%d/%d" % (status_int_cate, status_int_view),
                CmsNaviCategory.objects.get(id=view_second_category.service_id)
            ])
        except:
            continue
    # 添加到家服务
    view_second_categories = CmsViewService.objects.filter(open_type=5,
                                                           channel__id=channel)
    for view_second_category in view_second_categories:
        try:
            status_str_cate, status_int_cate = get_check_status_str(
                "CmsNaviCategory", view_second_category.service_id)
            status_str_view, status_int_view = get_check_status_str(
                "CmsViewService", view_second_category.id)
            items.append([
                "到家服务", "到家一级分类", status_str_view,
                "%d/%d" % (status_int_cate, status_int_view),
                CmsNaviCategory.objects.get(id=view_second_category.service_id)
            ])
        except:
            continue
    # 添加到家服务
    view_second_categories = CmsViewService.objects.filter(open_type=6,
                                                           channel__id=channel)
    for view_second_category in view_second_categories:
        try:
            status_str_cate, status_int_cate = get_check_status_str(
                "CmsNaviCategory", view_second_category.service_id)
            status_str_view, status_int_view = get_check_status_str(
                "CmsViewService", view_second_category.id)
            items.append([
                "到家服务", "到家二级分类", status_str_view,
                "%d/%d" % (status_int_cate, status_int_view),
                CmsNaviCategory.objects.get(id=view_second_category.service_id)
            ])
        except:
            continue
    result = []
    for group, type, status_str, status_int, item in items:
        # scene_name = get_scene_name(item.scene_id)
        if type == "服务" or type == "商品":
            location = item.location
        else:
            location = item.location2
        temp = [
            # scene_name,
            group,
            location,
            item.icon_url,
            item.name,
            item.dot_info,
            item.action_id,
            get_valid_time(item.valid_time),
            get_city_str(item.city),
            type,
            status_str,
            status_int,
            item.id
        ]
        result.append(temp)
    filter_none(result)
    result.sort(key=lambda o: (o[0], o[1]))
    return HttpResponse(json.dumps(result))
Exemplo n.º 18
0
def search_streams(request):
    channel = request.GET.get("channel")
    groups = CmsStreamcontent.objects.filter(cmsviewstream__channel__id=channel)
    result = []
    for group in groups:
        group_scene = get_scene_name(group.scene_id)
        group_type = get_2array_value(streams_type, group.type)
        status_str, status_int = get_check_status_str("CmsStreamcontent", group.id)
        item = {"group": [
            group_scene,
            group.location,
            group_type,
            status_str,
            status_int,
            group.id
        ], "members": []}
        # 商品
        goods = CmsGoods.objects.filter(cmsstreamcontentsgoods__streamcontent=group)
        for g in goods:
            status_str, status_int = get_check_status_str("CmsGoods", g.id)
            item["members"].append([
                g.icon_url,
                g.location,
                g.title,
                g.title_style,
                g.desc,
                g.desc_style,
                g.name,
                g.name_style,
                str(g.fav_price),
                g.fav_price_style,
                g.fav_price_desc,
                g.fav_price_desc_style,
                str(g.price),
                g.sold,
                g.action_id,
                get_valid_time(g.valid_time),
                get_city_str(g.city),
                "商品",
                status_str,
                0,
                status_int,
                g.id
            ])
        # 内容流
        beans = CmsStreamcontentbeans.objects.filter(cmsstreamcontentsbeans__streamcontent=group)
        for b in beans:
            status_str, status_int = get_check_status_str("CmsStreamcontentbeans", b.id)
            item["members"].append([
                b.img_url,
                b.location,
                b.title,
                b.title_style,
                b.descibe,
                b.descibe_style,
                b.name,
                b.name_style,
                str(b.price),
                b.price_style,
                b.price_desc,
                b.price_desc_style,
                str(b.price),
                b.sold,
                b.action_id,
                get_valid_time(b.valid_time),
                get_city_str(b.city),
                "内容流",
                status_str,
                1,
                status_int,
                b.id
            ])
        item["members"].sort(key=lambda o: (o[17], o[1]))
        result.append(item)
    filter_none(result)
    return HttpResponse(json.dumps(result))
Exemplo n.º 19
0
def search_category_pages_services(request):
    channel = request.GET.get("channel")
    groups = list(
        CmsNavicategories.objects.filter(cmsviewnavi__channel_id=channel))
    result = []
    try:
        groups.sort(key=lambda o: (CmsCategoryGroup.objects.get(
            cmsviewgroupcategory__category=o.category).name))
    except:
        pass
    for group in groups:
        # group_scene = get_scene_name(group.scene_id)
        open_type = 2
        try:
            group_name = CmsCategoryGroup.objects.get(
                cmsviewgroupcategory__category=group.category).name
            if group_name == CategoryGroupType.daojia:
                open_type = 1
            elif group_name == CategoryGroupType.live:
                open_type = 0
        except:
            group_name = ""
        try:
            status_str, status_int = get_check_status_str(
                "CmsNavicategories", group.id)
            item = {
                "group": [
                    # group_scene,
                    group_name,
                    group.location,
                    group.category.name,
                    group.name_style,
                    group.dot_info,
                    open_type,
                    status_str,
                    status_int,
                    group.id
                ],
                "members": []
            }
        except:
            continue
        # 分类
        navi_categories = CmsNavicatesCategory.objects.filter(cate=group)
        for navi_category in navi_categories:
            category = navi_category.category
            status_str_cate, status_int_cate = get_check_status_str(
                "CmsNaviCategory", category.id)
            status_str_view, status_int_view = get_check_status_str(
                "CmsNavicatesCategory", navi_category.id)
            item["members"].append([
                category.small_icon_url, category.location, "分类",
                category.name, category.name_style, category.desc,
                category.desc_style, category.search_keyword,
                category.dot_info, category.action_id,
                get_valid_time(category.valid_time),
                get_city_str(category.city), status_str_view, 1,
                "%d/%d" % (status_int_cate, status_int_view), category.id
            ])
        # 服务
        navi_services = CmsNavicatesServices.objects.filter(cate=group)
        for navi_service in navi_services:
            try:
                service = navi_service.service
            except:
                continue
            status_str, status_int = get_check_status_str(
                "CmsServices", service.id)
            item["members"].append([
                service.small_icon_url, service.location, "服务", service.name,
                service.name_style, service.desc, service.desc_style,
                service.search_keyword, service.dot_info, service.action_id,
                get_valid_time(service.valid_time),
                get_city_str(service.city), status_str, 2,
                "%d/%d" % (status_int, status_int), service.id
            ])
        # 商品
        navi_goods = CmsNavicatesGoods.objects.filter(cate=group)
        for navi_good in navi_goods:
            try:
                goods = navi_good.goods
            except:
                continue
            status_str, status_int = get_check_status_str("CmsGoods", goods.id)
            item["members"].append([
                goods.small_icon_url, goods.location, "商品", goods.name,
                goods.name_style, goods.desc, goods.desc_style,
                goods.search_keyword, goods.dot_info, goods.action_id,
                get_valid_time(goods.valid_time),
                get_city_str(goods.city), status_str, 3,
                "%d/%d" % (status_int, status_int), goods.id
            ])
        item["members"].sort(key=lambda o: (o[2], o[1]))
        result.append(item)
    filter_none(result)
    return HttpResponse(json.dumps(result))