コード例 #1
0
ファイル: second_category.py プロジェクト: cash2one/pt
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))
コード例 #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))
コード例 #3
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))
コード例 #4
0
ファイル: coupons.py プロジェクト: cash2one/pt
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))
コード例 #5
0
ファイル: likes.py プロジェクト: 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))
コード例 #6
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))
コード例 #7
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))
コード例 #8
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))
コード例 #9
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))