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))
def streams_exchange(request): id1 = request.POST.get("id1") type1 = request.POST.get("type1") id2 = request.POST.get("id2") type2 = request.POST.get("type2") channel_id = request.POST.get("channel") arr = [["0", CmsGoods], ["1", CmsStreamcontentbeans]] class1 = get_2array_value(arr, type1) class2 = get_2array_value(arr, type2) exchange_obj(class1, id1, class2, id2, channel_id, CmsModule.CONFIG_STREAM, request) return HttpResponse(0)
def exchange_category(request): id1 = request.POST.get("id1") id2 = request.POST.get("id2") channel_id = request.POST.get("channel") type1 = request.POST.get("type1") type2 = request.POST.get("type2") arr = [["1", CmsNaviCategory], ["2", CmsServices], ["3", CmsGoods]] class1 = get_2array_value(arr, type1) class2 = get_2array_value(arr, type2) exchange_obj(class1, id1, class2, id2, channel_id, CmsModule.CONFIG_PAGE, request) return HttpResponse(0)
def record_handle(request): filter_unsubmitted() records = CmsCheck.objects.filter( Q(status=CheckStatu.WAIT_SUBMIT) | Q(status=CheckStatu.SUBMIT)) result = [] for record in records: try: type, version, channel_no = show_cvt(record.channel_id, record.module) if str(record.status) == CheckStatu.SUBMIT: person = CmsCheck.objects.filter( channel_id=record.channel_id, module=record.module, status=record.status).last().submit_person else: person = "" data = [ get_2array_value(check_status, str(record.status)), person, type, version, channel_no, record.module ] except: continue set_id_into_records(result, data, record.id) result.sort(key=lambda o: (o["record"][0], o["record"][2], o["record"][3], o["record"][4], o["record"][5]), reverse=True) filter_none(result) return HttpResponse(json.dumps(result))
def show_cvt(channel_id, module): if channel_id: try: # 不是删除渠道 m = get_2array_value(item_modules, module) relate_channels = get_relate_channel_list(channel_id, m) relate_channels.append(channel_id) relate_channels.sort() types = [] channel_nos = [] app_versions = [] for channel in relate_channels: obj = CmsChannels.objects.get(id=channel) c, v, t = getCVT(channel) types.append(get_nav_text(str(t))) app_versions.append(v) channel_nos.append(obj.channel_no) return "<br />".join(types), "<br />".join( app_versions), "<br />".join(channel_nos) except: # 删除的是渠道,情况比较特殊 c, v, t = getCVT(channel_id, 'online') return get_nav_text(str(t)), v, c else: return "内容库", "内容库", "内容库"
def exchange_common_service(request): id1 = request.POST.get("id1") type1 = request.POST.get("type1") id2 = request.POST.get("id2") type2 = request.POST.get("type2") channel_id = request.POST.get("channel") arr = [["服务", [CmsServices, "location"]], ["商品", [CmsGoods, "location"]], ["功能一级分类", [CmsNaviCategory, "location2"]], ["功能二级分类", [CmsNaviCategory, "location2"]], ["到家一级分类", [CmsNaviCategory, "location2"]], ["到家二级分类", [CmsNaviCategory, "location2"]]] class1, word1 = get_2array_value(arr, type1) class2, word2 = get_2array_value(arr, type2) exchange_obj(class1, id1, class2, id2, channel_id, CmsModule.CONFIG_COMMON_SERVICES, request, word1=word1, word2=word2) return HttpResponse(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))
def get_record_history(): records = CmsCheck.objects.filter( Q(status=CheckStatu.PASS) | Q(status=CheckStatu.REJECT)) # Q(status=CheckStatu.REVERT) | result = [] for record in records: try: type, version, channel_no = show_cvt(record.channel_id, record.module) data = [ get_2array_value(check_status, str(record.status)), record.submit_person, type, version, channel_no, record.module, str(record.check_date) ] set_id_into_records(result, data, record.id) except: continue result.sort(key=lambda o: (o["record"][6]), reverse=True) filter_none(result) return result
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))
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))
def check_pass(request): """ 审核通过 :param url: {% url 'check_pass' %} :param ids: 审核表id列表 :return: 0 表示成功 """ ids = json.loads(request.POST.get("ids")) check_time = time.strftime("%Y-%m-%d %X", time.localtime()) records = CmsCheck.objects.filter(id__in=ids) result = split_checks(records) try: for r in result: history = CmsCheckHistory( status=get_2array_value(check_status, CheckStatu.PASS), check_person=request.user.username, check_date=check_time, type=r["record"][1], version=r["record"][2], channel_no=r["record"][3], module=r["record"][4], submit_person=r["record"][0], submit_date=r["record"][5], content=json.dumps(get_record_detail(r["ids"])), ) history.save() for id in ids: oCmsCheck = CmsCheck.objects.get(id=id) # 如果是新建和编辑的话直接同步到正式库,删除就直接删除 if oCmsCheck.op_type == int(CheckOpType.NEW): if oCmsCheck.table_name == "CmsChannelChannel": pass_channelchannel(oCmsCheck.data_id, oCmsCheck.is_show) else: table_obj = eval( oCmsCheck.table_name).objects.get(id=oCmsCheck.data_id) table_obj.save(using="online") elif oCmsCheck.op_type == int(CheckOpType.EDIT): table_obj = eval( oCmsCheck.table_name).objects.get(id=oCmsCheck.data_id) table_obj.save(using="online") else: if oCmsCheck.table_name == "CmsChannels": DelChannel.del_index_channel(oCmsCheck.data_id, db="online") elif oCmsCheck.table_name == "CmsViewFindTopic": table_obj = eval( oCmsCheck.table_name).objects.get(id=oCmsCheck.data_id) table_obj.save(using="online") else: eval(oCmsCheck.table_name).objects.using("online").filter( id=oCmsCheck.data_id).delete() oCmsCheck.status = CheckStatu.PASS oCmsCheck.check_person = request.user.username oCmsCheck.check_date = check_time if oCmsCheck.op_type == int(CheckOpType.DELETE): CmsCheck.objects.filter(table_name=oCmsCheck.table_name, data_id=oCmsCheck.data_id).delete() else: oCmsCheck.save() except Exception as ex: for r in result: history = CmsCheckHistory( status=get_2array_value(check_status, CheckStatu.CHECK_ERROR), check_person=request.user.username, check_date=check_time, type=r["record"][1], version=r["record"][2], channel_no=r["record"][3], module=r["record"][4], submit_person=r["record"][0], submit_date=r["record"][5], content=json.dumps(get_record_detail(r["ids"])), ) history.save() for id in ids: oCmsCheck = CmsCheck.objects.get(id=id) oCmsCheck.status = CheckStatu.SUBMIT oCmsCheck.check_person = request.user.username oCmsCheck.check_date = check_time oCmsCheck.remark = "exception:%s" % ex.args[0] oCmsCheck.save() return HttpResponse(0)