def delete_choiceness_category(request): id = request.POST.get("id") channel_id = request.POST.get("channel") views = CmsViewChoicenessCategory.objects.filter(choiceness_category_id=id) for view in views: if CMS_CHECK_ON: check = CmsCheck( channel_id=channel_id, module=CmsModule.CONFIG_CHOICENESS, table_name="CmsViewChoicenessCategory", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() view.delete() CmsChoicenessCategory.objects.get(id=id).delete() if CMS_CHECK_ON: check = CmsCheck( channel_id=channel_id, module=CmsModule.CONFIG_CHOICENESS, table_name="CmsChoicenessCategory", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_bean(request): bean = request.POST.get("bean") channel_id = request.POST.get("channel") oCmsAdsBeans = CmsAdsBeans.objects.get(bean_id=bean) if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_AD, table_name="CmsAdsBeans", data_id=oCmsAdsBeans.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() oCmsAdsBeans.delete() CmsAdbeans.objects.get(id=bean).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_AD, table_name="CmsAdbeans", data_id=bean, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_activity(request): id = request.POST.get("id") channel_id = request.POST.get('channel') views = CmsViewNativeActivity.objects.filter(nactivity_id=id) if CMS_CHECK_ON: for view in views: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_NATIVE_ACTIVITY, table_name="CmsViewNativeActivity", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() views.delete() CmsNativeActivity.objects.filter(id=id).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_NATIVE_ACTIVITY, table_name="CmsNativeActivity", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_goods(request): id = request.POST.get("id") channel_id = request.POST.get('channel') cmsnavicatesgoods = CmsNavicatesGoods.objects.get(goods_id=id) if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsNavicatesGoods", data_id=cmsnavicatesgoods.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() cmsnavicatesgoods.delete() CmsGoods.objects.get(id=id).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsGoods", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_common_category(request): id = request.POST.get("id") channel = request.POST.get("channel") related_channels = get_relate_channel_list(channel, CONFIG_ITEMS.COMMON_SERVICES) related_channels.append(channel) for channel_id in related_channels: views = CmsViewService.objects.filter(service_id=id, channel_id=channel_id, open_type__in=[3, 4, 5, 6]) for view in views: if CMS_CHECK_ON: is_show = 0 if int(view.channel_id) == int(channel): is_show = 1 check = CmsCheck(channel_id=channel, module=CmsModule.CONFIG_COMMON_SERVICES, table_name="CmsViewService", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=is_show, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() view.delete() return HttpResponse(0)
def mark_info_foundpage(request): id = request.POST.get("id") mark_info = request.POST.get("mark_info") channel_id = request.POST.get("channel") relate_channels = get_relate_channel_list(channel_id, CONFIG_ITEMS.FOUNDPAGE) relate_channels.append(channel_id) for c in relate_channels: find_topics = CmsViewFindTopic.objects.filter(topic_id=id, channel_id=c, is_deleted=0) for find_topic in find_topics: find_topic.mark_info = mark_info find_topic.save() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_FOUNDPAGE, table_name="CmsViewFindTopic", data_id=find_topic.id, op_type=CheckOpType.EDIT, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_common_goods(request): id = request.POST.get("id") channel = request.POST.get("channel") views = CmsViewService.objects.filter(service_id=id, open_type=1) for view in views: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel, module=CmsModule.CONFIG_COMMON_SERVICES, table_name="CmsViewService", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() view.delete() CmsGoods.objects.get(id=id).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel, module=CmsModule.CONFIG_COMMON_SERVICES, table_name="CmsGoods", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_config_operation(request): id = request.POST.get("id") channel_id = request.POST.get('channel') views = CmsViewOpconfig.objects.filter(opconfig_id=id) for view in views: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_OPERATION, table_name="CmsViewOpconfig", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() view.delete() CmsOpconfig.objects.filter(id=id).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_OPERATION, table_name="CmsOpconfig", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_homepage_specialtopic(request): id = request.POST.get("id") channel_id = request.POST.get("channel") relate_channels = get_relate_channel_list(channel_id, CONFIG_ITEMS.HOMEPAGE) relate_channels.append(channel_id) for c in relate_channels: hometopics = CmsViewHomepageTopic.objects.filter(topic=id, channel=c) for hometopic in hometopics: if CMS_CHECK_ON: is_show = 0 remark = "" if int(c) == int(channel_id): is_show = 1 remark = "删除标题为%s的首页专题" % CheckManager.wrap_style( hometopic.topic.title) check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_HOMEPAGE, table_name="CmsViewHomepageTopic", data_id=hometopic.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=is_show, remark=remark, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() hometopic.delete() return HttpResponse(0)
def delete_ad(request): channel_id = request.POST.get("channel") ad = request.POST.get("ad") views = CmsViewAd.objects.filter(ad_id=ad) if CMS_CHECK_ON: for view in views: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_AD, table_name="CmsViewAd", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() views.delete() adsbeans = CmsAdsBeans.objects.filter(ad_id=ad) for adsbean in adsbeans: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_AD, table_name="CmsAdsBeans", data_id=adsbean.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_AD, table_name="CmsAdbeans", data_id=adsbean.bean_id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() adsbean.bean.delete() adsbeans.delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_AD, table_name="CmsAds", data_id=ad, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() CmsAds.objects.get(id=ad).delete() return HttpResponse(0)
def delete_shop(request): id = request.POST.get("id") CmsCategoryItembean.objects.get(id=id).delete() if CMS_CHECK_ON: check = CmsCheck( module=CmsModule.MAIN_SHOP, table_name="CmsCategoryItembean", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X",time.localtime())) check.save() return HttpResponse(0)
def delete_category(request): id = request.POST.get("id") channel_id = request.POST.get('channel') groups = CmsNavicatesCategory.objects.filter( category_id=id, cate__cmsviewnavi__channel_id=channel_id) for group in groups: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsNavicatesCategory", data_id=group.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, remark="在id为%s的分类组删除了名称为%s的分类" % (CheckManager.wrap_style(group.cate.id), CheckManager.wrap_style(group.category.name)), alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() group.delete() return HttpResponse(0)
def delete_foundpage_specialtopic(request): id = request.POST.get("id") channel_id = request.POST.get("channel") relate_channels = get_relate_channel_list(channel_id, CONFIG_ITEMS.FOUNDPAGE) relate_channels.append(channel_id) for c in relate_channels: find_topics = CmsViewFindTopic.objects.filter(topic_id=id, channel_id=c, is_deleted=0) for find_topic in find_topics: find_topic.is_deleted = 1 # find_topic.update_time = timezone.now() find_topic.delete_time = time.timezone.now() find_topic.save() if CMS_CHECK_ON: is_show = 0 remark = "" if int(c) == int(channel_id): is_show = 1 remark = "删除标题为%s的发现页专题" % (CheckManager.wrap_style( CmsSpecialTopic.objects.get( id=find_topic.topic_id).title), ) check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_FOUNDPAGE, table_name="CmsViewFindTopic", data_id=find_topic.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=is_show, remark=remark, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def new_activity(request, template_name): """ 配置库 本地活动 url :{% url 'new_native_activity' %}?channel={{ channel }} :请求方式: Get :请求参数:channel :返回数据:fields errors scenes 场景列表 open_type(类别) citygroups cities :例如:scenes 场景列表 和之前一样 :请求方式:Post :请求参数: """ channel_id = request.GET.get('channel') c, v, t = getCVT(channel_id) channel = CmsChannels.objects.get(id=channel_id) # 根据类型得到名称 text = get_nav_text(str(t)) times = ['start_time', 'end_time', 'open_time', 'close_time'] if request.method == 'POST': form = CmsNativeActivityForm(request.POST) for time1 in times: if form.data[time1]: form.data[time1] = make_timestamp(form.data[time1]) if form.is_valid(): activity = form.save() import time if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_NATIVE_ACTIVITY, table_name="CmsNativeActivity", data_id=activity.id, op_type=CheckOpType.NEW, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() new_associate(channel_id, activity.id, CONFIG_ITEMS.NATIVE_ACTIVITY, request) oCmsViewNativeActivity = CmsViewNativeActivity(nactivity=activity, channel=channel) oCmsViewNativeActivity.save() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_NATIVE_ACTIVITY, table_name="CmsViewNativeActivity", data_id=oCmsViewNativeActivity.id, op_type=CheckOpType.NEW, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() return HttpResponseRedirect( reverse("native_activities") + "?t=%d&c=%s&v=%s" % (t, c, v)) else: form = ActivitiesForm() actions = get_actions_select() scenes = get_scenes() cities = get_city_list() citygroups = get_city_group() errors, fields = format_form(form) for time in times: if time in fields.keys() and json.loads(fields[time]): fields[time] = json.dumps(timestamp2str(fields[time])) return render_to_response(template_name, { "scenes": scenes, "actions": actions, "fields": fields, "errors": errors, "cities": cities, "citygroups": citygroups, "open_type": open_type, "t": t, "c": c, "v": v, "text": text, "channel": channel_id }, context_instance=RequestContext(request))
def delete_group(request): id = request.POST.get("id") channel_id = request.POST.get('channel') cmsnavicategoods = CmsNavicatesGoods.objects.filter(cate_id=id) for cmsnavicategood in cmsnavicategoods: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsNavicatesGoods", data_id=cmsnavicategood.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsGoods", data_id=cmsnavicategood.goods.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() cmsnavicategood.goods.delete() cmsnavicategood.delete() cmsnavicateservices = CmsNavicatesServices.objects.filter(cate_id=id) for cmsnavicateservice in cmsnavicateservices: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsNavicatesServices", data_id=cmsnavicateservice.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsServices", data_id=cmsnavicateservice.service.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() cmsnavicateservice.service.delete() cmsnavicateservice.delete() cmsnavicatescategorys = CmsNavicatesCategory.objects.filter(cate_id=id) for cmsnavicatescategory in cmsnavicatescategorys: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsNavicatesCategory", data_id=cmsnavicatescategory.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() cmsnavicatescategory.delete() related_channels = get_relate_channel_list( channel_id, CONFIG_ITEMS.CATEGORY_PAGE_SERVICES) related_channels.append(channel_id) for channel in related_channels: views = CmsViewNavi.objects.filter(navicat_id=id, channel_id=channel) for view in views: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsViewNavi", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime( "%Y-%m-%d %X", time.localtime())) check.save() view.delete() CmsNavicategories.objects.get(id=id).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_PAGE, table_name="CmsNavicategories", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)
def delete_group(request): id = request.POST.get("id") channel_id = request.POST.get('channel') views = CmsViewLike.objects.filter(like_id=id) for view in views: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_LIKE, table_name="CmsViewLike", data_id=view.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() views.delete() cmslikesgoods = CmsLikesGoods.objects.filter(like_id=id) for cmslikesgood in cmslikesgoods: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_LIKE, table_name="CmsGoods", data_id=cmslikesgood.goods.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_LIKE, table_name="CmsLikesGoods", data_id=cmslikesgood.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() cmslikesgood.goods.delete() cmslikesgoods.delete() cmslikesservices = CmsLikesServices.objects.filter(like_id=id) for cmslikesservice in cmslikesservices: if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_LIKE, table_name="CmsServices", data_id=cmslikesservice.service.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_LIKE, table_name="CmsLikesServices", data_id=cmslikesservice.id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=0, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() cmslikesservice.service.delete() cmslikesservices.delete() CmsLikes.objects.get(id=id).delete() if CMS_CHECK_ON: check = CmsCheck(channel_id=channel_id, module=CmsModule.CONFIG_LIKE, table_name="CmsLikes", data_id=id, op_type=CheckOpType.DELETE, status=CheckStatu.WAIT_SUBMIT, is_show=1, alter_person=request.user.username, alter_date=time.strftime("%Y-%m-%d %X", time.localtime())) check.save() return HttpResponse(0)