def search_actions(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 = CmsActions.objects.all() actions = [] for obj in objs: if obj.type == 1: type = "打开特定服务页面" elif obj.type == 2: type = "打开特定链接H5页面" else: type = "" status_str, status_int = get_check_status_str("CmsActions", obj.id) actions.append([ obj.id, obj.dest_title, type, obj.dest_activity, obj.dest_url, obj.cp_info, status_str, status_int, obj.id ]) result = search_key(actions, key, [7, 8]) result, num_pages = get_table_paginator(result, per_page, cur_page) filter_none(result) return HttpResponse(json.dumps([list(result), num_pages]))
def search_cps(request): """CP数据""" 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 = CmsCP.objects.all().order_by("-sort") cps = [] for obj in objs: try: category = CmsViewCP.objects.get(cp=obj).cp_category.name except: category = "" status_str, status_int = "", 1 cps.append([ obj.id, obj.name, obj.desc, obj.icon, category, # obj.location1, obj.location2, status_str, obj.tag_in_list, obj.sort, status_int, obj.id ]) key = request.GET.get("key") cps = search_key(cps, key, [2, 7, 8]) result, num_pages = get_table_paginator(cps, per_page, cur_page) return HttpResponse(json.dumps([list(result), num_pages]))
def search_static_data(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 = CmsCategoryItembean.objects.filter(parent_id=-1) shops = [] for obj in objs: photoUrl, photo_str, search_show, s_key, search_category, home, weibo = analyze_shop_content(obj) status_str, status_int = get_check_status_str("CmsCategoryItembean", obj.id) shops.append([ photoUrl, obj.name, photo_str, search_show, s_key, search_category, home, weibo, status_str, status_int, obj.id ]) key = request.GET.get("key") shops = search_key(shops, key, [0, 9, 10]) result,num_pages = get_table_paginator(shops,per_page,cur_page) return HttpResponse(json.dumps([list(result),num_pages]))
def search_image(request): per_page = request.GET.get("per_page", 36) cur_page = request.GET.get("cur_page", 1) key = request.GET.get("key") image_category = request.GET.get('image_category') search_datas = CmsImageInfo.objects.filter( image_category=image_category, image_name__contains=key).values_list('image_name', 'image_category', 'image_url', 'id') images = check_submitted_results('CmsImageInfo', search_datas, -1) result, num_pages = get_table_paginator(images, per_page, cur_page) # return HttpResponse(json.dumps([list(result), num_pages])) c = json.dumps([list(result), num_pages]) return HttpResponse(c)
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]))
def search_cp_category(request): """CP分类数据""" 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 = CmsCPCategory.objects.all() categories = [] for obj in objs: status_str, status_int = "", 1 categories.append( [obj.name, obj.location, status_str, status_int, obj.id]) key = request.GET.get("key") categories = search_key(categories, key, [3, 4]) result, num_pages = get_table_paginator(categories, per_page, cur_page) return HttpResponse(json.dumps([list(result), num_pages]))
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]))
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]))
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]))
def search_problem(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 = CmsProblem.objects.all().order_by('-sort') problems = [] for obj in objs: status_str, status_int = get_check_status_str("CmsProblem", obj.id) problems.append([ obj.problem, obj.answer, obj.sort, obj.id ]) result = search_key(problems, key, [2, 3]) result, num_pages = get_table_paginator(result, per_page, cur_page) filter_none(result) return HttpResponse(json.dumps([list(result), num_pages]))
def search_categories(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") categories = list(CmsNaviCategory.objects.filter(parent_id=0, fatherid=0)) try: categories.sort(key=lambda o: (CmsCategoryGroup.objects.get( cmsviewgroupcategory__category=o).name)) except: pass result = [] temp = "" for category in categories: # used_by_op = "是" if category.used_by_op else "否" # show_style = get_show_style(category.show_style) status_str, status_int = get_check_status_str("CmsNaviCategory", category.id) try: group_name = CmsCategoryGroup.objects.get( cmsviewgroupcategory__category=category).name if temp != group_name: group = group_name else: group = "" temp = group_name except: group = "" if category.type == 0: category_type = "旧分类" else: category_type = "新分类" result.append([ group, category.name, category.name_style, category.desc, category.desc_style, category.search_keyword, # used_by_op, # show_style, category_type, status_str, 0, status_int, category.id ]) children = CmsNaviCategory.objects.filter(parent_id=0, fatherid=category.id) for c in children: # used_by_op = "是" if c.used_by_op else "否" # show_style = get_show_style(category.show_style) status_str, status_int = get_check_status_str( "CmsNaviCategory", c.id) result.append([ "", c.name, c.name_style, c.desc, c.desc_style, c.search_keyword, # used_by_op, # show_style, "", status_str, 1, status_int, c.id ]) result = search_key(result, key, [2, 4, 8, 9, 10]) result, num_pages = get_table_paginator(result, per_page, cur_page) filter_none(result) return HttpResponse(json.dumps([list(result), num_pages]))