示例#1
0
 def del_index_version(cls, ver_id, request, db="default"):
     # 按照渠道删除步骤,删除该版本下的所有渠道
     channels = CmsChannels.objects.using(db).filter(app_version_id=ver_id)
     for channel in channels:
         cls.del_index_channel(channel.id, db)
         if CMS_CHECK_ON:
             CmsCheck(module=CmsModule.MAIN_CHANNEL,
                      table_name='CmsChannels',
                      data_id=channel.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())).save()
     # 删除该版本信息
     CmsChannelsAppVersion.objects.using(db).get(id=ver_id).delete()
     if CMS_CHECK_ON:
         CmsCheck(module=CmsModule.MAIN_CHANNEL,
                  table_name='CmsChannelsAppVersion',
                  data_id=ver_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())).save()
示例#2
0
def copy_version(source_version_id, target_version_id, request):
    # 复制到
    channels = CmsChannels.objects.filter(app_version_id=source_version_id)
    for channel in channels:
        channel.app_version_id = target_version_id
        src_channel_id = channel.id
        channel.id = None
        channel.save()
        if CMS_CHECK_ON:
            CmsCheck(module=CmsModule.MAIN_CHANNEL,
                     table_name='CmsChannels',
                     data_id=channel.id,
                     op_type=CheckOpType.NEW,
                     is_show=0,
                     alter_person=request.user.username,
                     alter_date=time.strftime("%Y-%m-%d %X",
                                              time.localtime())).save()
        ocmschannelchannel = OpChannel(src_channel_id).copy_asso(channel.id)
        if CMS_CHECK_ON:
            CmsCheck(module=CmsModule.MAIN_CHANNEL,
                     table_name='CmsChannelChannel',
                     data_id=ocmschannelchannel.id,
                     op_type=CheckOpType.NEW,
                     is_show=0,
                     alter_person=request.user.username,
                     alter_date=time.strftime("%Y-%m-%d %X",
                                              time.localtime())).save()
示例#3
0
def new_streamsgroup(request, template_name):
    """
    新建 内容流组
    url :{% url 'new_streamsgroup' %}?channel={{ channel }}
    :请求方式: Get
    :请求参数:channel
    :返回数据:form 表单 scenes 场景列表 streams_type:类型
    :例如:scenes 场景列表 和之前一样 streams_type = [[1,"活动"],[2,"服务"],[3,"商品"],[4,"搜索"]]

    :请求方式:Post
    :请求参数:`type` `location`  `scene_id`
    """
    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))
    if request.method == 'POST':
        form = StreamcontentForm(request.POST)
        if form.is_valid():
            streamcontent = form.save()
            if CMS_CHECK_ON:
                CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_STREAM,
                         table_name='CmsStreamcontent',
                         data_id=streamcontent.id,
                         op_type=CheckOpType.NEW,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X", time.localtime())).save()
            oCmsViewStream = CmsViewStream(streamcontent=streamcontent, channel=channel, status=0)
            oCmsViewStream.save()
            if CMS_CHECK_ON:
                CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_STREAM,
                         table_name='CmsViewStream',
                         data_id=oCmsViewStream.id,
                         op_type=CheckOpType.NEW,
                         is_show=0,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X", time.localtime())).save()
            new_associate(channel_id, streamcontent.id, CONFIG_ITEMS.STREAMS, request)
            return HttpResponseRedirect(reverse("streams") + "?t=%d&c=%s&v=%s" % (t, c, v))
    else:
        form = CmsAdsForm()
    scenes = get_scenes()
    errors, fields = format_form(form)
    return render_to_response(template_name, {
        "scenes": scenes,
        "streams_type": streams_type,
        "fields": fields,
        "errors": errors,
        "t": t,
        "c": c,
        "v": v,
        "text": text,
        "channel": channel_id
    }, context_instance=RequestContext(request))
示例#4
0
def edit_specialtopic(request, template_name):
    """
    编辑专题
    url :{% url 'edit_specialtopic' %}?id={{ id }}
    :请求方式: Get
    :请求参数:id
    :返回数据:scenes 场景列表 citygroups 城市分组列表,cities 所有城市(列表) actions 动作列表 open_type 类型
    :[[id,name],[id,name],....]

    :请求方式:Post
    :请求参数:数据库字段(input name)
    """
    id = request.GET.get("id")
    specialtopic = CmsSpecialTopic.objects.get(id=id)
    if request.method == "POST":
        form = SpecialTopicForm(request.POST, instance=specialtopic)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_TOPIC,
                         table_name='CmsSpecialTopic',
                         data_id=id,
                         op_type=CheckOpType.EDIT).save()
            find_page_views = CmsViewFindTopic.objects.filter(topic_id=id)
            # 更新时间同步
            for find_page_view in find_page_views:
                find_page_view.update_time = specialtopic.update_time
                find_page_view.save()
                if CMS_CHECK_ON:
                    CmsCheck(module=CmsModule.MAIN_TOPIC,
                             table_name='CmsViewFindTopic',
                             data_id=find_page_view.id,
                             op_type=CheckOpType.EDIT,
                             is_show=0,
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
            return HttpResponseRedirect(reverse("specialtopics"))
    else:
        form = SpecialTopicForm(instance=specialtopic)
    errors, fields = format_form(form)
    citygroups = get_city_group()
    actions = get_actions_select()
    cities = get_city_list()
    scenes = get_scenes()
    return render_to_response(template_name, {
        "fields": fields,
        "errors": errors,
        "citygroups": citygroups,
        "actions": actions,
        "cities": cities,
        "scenes": scenes,
        "open_type": open_type,
        "id": id
    },
                              context_instance=RequestContext(request))
示例#5
0
def new_shop(request):
    """
     新建二级分类 商户
    :请求方式:ajax Post
    :请求URL:{% url 'sc_new_shop' %}
    :请求参数:shop_id 商户id category_item_id 二级分类id
    :类型 :传数字
    返回: 成功:0 错误:错误信息
    """

    if request.method == 'POST':
        data = request.POST.copy()
        error = ""
        for key in data:
            if data[key] == "":
                error += key + " is null \n"
        if error:
            return HttpResponse(error)
        else:
            try:
                shop_id = request.POST.get("shop_id")
                category_item_id = request.POST.get("category_item_id")
                channel_id = request.POST.get("channel_id")
                category_itembean = CmsCategoryItembean.objects.get(id=shop_id)
                category_itembean.parent_id = shop_id
                category_itembean.id = None
                category_itembean.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_SECOND_CATEGORY,
                             table_name='CmsCategoryItembean',
                             data_id=category_itembean.id,
                             op_type=CheckOpType.NEW,
                             remark="添加商户名为%s的商户" %
                             CheckManager.wrap_style(category_itembean.name),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
                oCmsCategoryitemItembean = CmsCategoryitemItembean(
                    category_item=CmsCategoryItem.objects.get(
                        id=category_item_id),
                    item_bean=category_itembean)
                oCmsCategoryitemItembean.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_SECOND_CATEGORY,
                             table_name='CmsCategoryitemItembean',
                             data_id=oCmsCategoryitemItembean.id,
                             op_type=CheckOpType.NEW,
                             is_show=0,
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
            except Exception as ex:
                return HttpResponse(ex.args[0])
            return HttpResponse(0)
示例#6
0
def new_channel(request):
    try:
        form = NewChannelForm(request.POST)
        type_id = request.POST.get("channel_type_id")
        source_channel_id = request.POST.get("source_channel_id")
        config_items = request.POST.get("config_items")
        config_items = json.loads(config_items)
        channel_op_type = request.POST.get("channel_op_type")
        if form.is_valid():
            channel_no = request.POST.get("channel_no")
            app_version = request.POST.get("input_app_version")
            if request.POST.get("order") == "1":
                order = 1
            else:
                order = 2
            app_obj = CmsChannelsAppVersion.objects.get(
                type_id=type_id, app_version=app_version)
            channel = CmsChannels(app_version=app_obj,
                                  channel_no=channel_no,
                                  user_id=1,
                                  order=order)
            channel.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_CHANNEL,
                         table_name='CmsChannels',
                         data_id=channel.id,
                         op_type=CheckOpType.NEW,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            if channel_op_type and source_channel_id and config_items:
                ocmschannelchannel = OpChannel(source_channel_id).copy_asso(
                    channel.id,
                    config_items=config_items,
                    channel_op_type=channel_op_type)
                if CMS_CHECK_ON:
                    CmsCheck(module=CmsModule.MAIN_CHANNEL,
                             table_name='CmsChannelChannel',
                             data_id=ocmschannelchannel.id,
                             op_type=CheckOpType.NEW,
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
            return HttpResponse(0)
        else:
            errors = ""
            for item in form.errors:
                errors += (item + ":" + form.errors[item][0] + "\n")
            return HttpResponse(json.loads(errors))
    except Exception as ex:
        return HttpResponse(ex.args[0])
示例#7
0
def new_goods(request):
    """
     新建 内容流 商品
    :请求方式:ajax Post
    :请求URL:{% url 'streams_new_goods' %}
    :请求参数:goods_id(商品id) group_id(内容流组id)
    :类型 :传数字
    返回: 成功:0 错误:错误信息
    """

    if request.method == 'POST':
        data = request.POST.copy()
        error = ""
        for key in data:
            if data[key] == "":
                error += key + " is null \n"
        if error:
            return HttpResponse(error)
        else:
            try:
                goods_id = request.POST.get("goods_id")
                group_id = request.POST.get("group_id")
                channel_id = request.POST.get("channel_id")
                streamcontent = CmsStreamcontent.objects.get(id=group_id)
                goods = CmsGoods.objects.get(id=goods_id)
                goods.parent_id = goods_id
                goods.id = None
                goods.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_STREAM,
                             table_name='CmsGoods',
                             data_id=goods.id,
                             op_type=CheckOpType.NEW,
                             remark="增加了名称为%s的商品" % (CheckManager.wrap_style(goods.name),),
                             alter_person=request.user.username,
                             alter_date=time.strftime("%Y-%m-%d %X", time.localtime())).save()
                oCmsStreamcontentsGoods = CmsStreamcontentsGoods(streamcontent=streamcontent, goods=goods)
                oCmsStreamcontentsGoods.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_STREAM,
                             table_name='CmsStreamcontentsGoods',
                             data_id=oCmsStreamcontentsGoods.id,
                             op_type=CheckOpType.NEW,
                             is_show=0,
                             alter_person=request.user.username,
                             alter_date=time.strftime("%Y-%m-%d %X", time.localtime())).save()
            except Exception as ex:
                return HttpResponse(ex.args[0])
            return HttpResponse(0)
示例#8
0
def delete_content_stream(request):
    id = request.POST.get("id")
    channel_id = request.POST.get("channel")
    streamcontentsbeans = CmsStreamcontentsBeans.objects.get(bean_id=id)
    if CMS_CHECK_ON:
        check = CmsCheck(
            channel_id=channel_id,
            module=CmsModule.CONFIG_STREAM,
            table_name="CmsStreamcontentsBeans",
            data_id=streamcontentsbeans.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()
    streamcontentsbeans.delete()
    CmsStreamcontentbeans.objects.get(id=id).delete()
    if CMS_CHECK_ON:
        check = CmsCheck(
            channel_id=channel_id,
            module=CmsModule.CONFIG_STREAM,
            table_name="CmsStreamcontentbeans",
            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)
示例#9
0
def delete_shop(request):
    id = request.POST.get("id")
    channel_id = request.POST.get("channel")
    oCmsCategoryitemItembean = CmsCategoryitemItembean.objects.get(
        item_bean_id=id)
    if CMS_CHECK_ON:
        check = CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_SECOND_CATEGORY,
                         table_name="CmsCategoryitemItembean",
                         data_id=oCmsCategoryitemItembean.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()
    oCmsCategoryitemItembean.delete()
    CmsCategoryItembean.objects.get(id=id).delete()
    if CMS_CHECK_ON:
        check = CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_SECOND_CATEGORY,
                         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)
示例#10
0
def delete_ad(request):
    id = request.POST.get("id")
    channel_id = request.POST.get('channel')
    views = CmsViewScreenads.objects.filter(screenad_id=id)
    if CMS_CHECK_ON:
        for view in views:
            check = CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_SCREEN_AD,
                             table_name="CmsViewScreenads",
                             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()
    CmsScreenads.objects.filter(id=id).delete()
    if CMS_CHECK_ON:
        check = CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_SCREEN_AD,
                         table_name="CmsScreenads",
                         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)
示例#11
0
文件: category.py 项目: cash2one/pt
def del_category(request):
    id = request.POST.get("id")
    # 删除二级分类
    children = CmsNaviCategory.objects.filter(parent_id=0, fatherid=id)
    if CMS_CHECK_ON:
        for child in children:
            check = CmsCheck(module=CmsModule.MAIN_CATEGORY,
                             table_name="CmsNaviCategory",
                             data_id=child.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()
    children.delete()
    # 删除一级分类
    parent = CmsNaviCategory.objects.filter(id=id)
    if CMS_CHECK_ON:
        check = CmsCheck(module=CmsModule.MAIN_CATEGORY,
                         table_name="CmsNaviCategory",
                         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()
    parent.delete()
    return HttpResponse(0)
示例#12
0
def del_goods(request):
    id = request.POST.get('id')
    goods = CmsGoods.objects.get(id=id)
    if CMS_CHECK_ON:
        check = CmsCheck(module=CmsModule.MAIN_GOODS,
                         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()
    goods.delete()
    return HttpResponse(0)
示例#13
0
def edit_service(request, template_name):
    id = request.GET.get("id")
    if request.method == "POST":
        services = CmsServices.objects.get(id=id)
        form = ServiceForm(request.POST, instance=services)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_SERVICE,
                         table_name='CmsServices',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse('services'))
    else:
        services = CmsServices.objects.get(id=id)
        form = ServiceForm(instance=services)
    errors, fields = format_form(form)
    scenes = get_scenes()
    actions = get_actions_select()
    citygroups = get_city_group()
    cities = get_city_list()
    return render_to_response(template_name, {
        "scenes": scenes,
        "actions": actions,
        "citygroups": citygroups,
        "cities": cities,
        "id": id,
        "fields": fields,
        "errors": errors
    },
                              context_instance=RequestContext(request))
示例#14
0
def edit_action(request, template_name):
    id = request.GET.get("id")
    if request.method == 'POST':
        actions = CmsActions.objects.get(id=id)
        form = ActionForm(request.POST, instance=actions)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_ACTION,
                         table_name='CmsActions',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse('actions'))
    else:
        actions = CmsActions.objects.get(id=id)
        form = ActionForm(instance=actions)
    errors, fields = format_form(form)
    return render_to_response(template_name, {
        "id": id,
        "errors": errors,
        "fields": fields
    },
                              context_instance=RequestContext(request))
示例#15
0
def new_version(request):
    type_id = request.POST["type_id"]
    src_ver_id = request.POST.get('src_ver_id')
    form = NewVerForm(request.POST)
    if form.is_valid():
        channelsappversion = form.save()
        remark = ""
        if src_ver_id:
            src_ver = CmsChannelsAppVersion.objects.get(id=src_ver_id)
            src_ver_text = src_ver.app_version
            src_type_text = get_nav_text(src_ver.type_id)
            type_text = get_nav_text(type_id)
            remark = "在%s下新建了版本%s,它是由%s%s版本复制而来" % (
                type_text, channelsappversion.app_version, src_type_text,
                src_ver_text)
        if CMS_CHECK_ON:
            CmsCheck(module=CmsModule.MAIN_CHANNEL,
                     table_name='CmsChannelsAppVersion',
                     data_id=channelsappversion.id,
                     op_type=CheckOpType.NEW,
                     remark=remark,
                     alter_person=request.user.username,
                     alter_date=time.strftime("%Y-%m-%d %X",
                                              time.localtime())).save()
        if src_ver_id:
            copy_version(src_ver_id, channelsappversion.id, request)
    return HttpResponseRedirect(reverse('main_index') + "?t=%s" % type_id)
示例#16
0
def new_goods(request, template_name):
    if request.method == "POST":
        second_category = request.POST.get("second_category")
        if second_category:
            second_category = CmsNaviCategory.objects.get(id=second_category)
            if second_category.fatherid == 0:
                request.POST["category"] = request.POST["second_category"]
                request.POST['second_category'] = None
            else:
                request.POST["category"] = second_category.fatherid
        new_second_category = request.POST.get("new_second_category")
        if new_second_category:
            new_second_category = CmsNaviCategory.objects.get(
                id=new_second_category)
            if new_second_category.fatherid == 0:
                request.POST["new_category"] = request.POST[
                    "new_second_category"]
                request.POST['new_second_category'] = None
            else:
                request.POST["new_category"] = new_second_category.fatherid
        form = GoodsForm(request.POST)
        if form.is_valid():
            oGoods = form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_GOODS,
                         table_name='CmsGoods',
                         data_id=oGoods.id,
                         op_type=CheckOpType.NEW,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse('goods'))
    else:
        form = GoodsForm()
    errors, fields = format_form(form)
    if 'second_category' in fields.keys(
    ) and fields['second_category'] == '""':
        fields['second_category'] = fields['category']
    if 'new_second_category' in fields.keys(
    ) and fields['new_second_category'] == '""':
        fields['new_second_category'] = fields['new_category']
    scenes = get_scenes()
    actions = get_actions_select()
    citygroups = get_city_group()
    cities = get_city_list()
    categories = get_categories()
    return render_to_response(template_name, {
        "scenes": scenes,
        "actions": actions,
        "citygroups": citygroups,
        "categories": categories,
        "cities": cities,
        "fields": fields,
        "errors": errors
    },
                              context_instance=RequestContext(request))
示例#17
0
def edit_shop(request, template_name):
    """
    编辑二级 商户
    url :{% url 'sc_edit_shop' %}?channel={{ channel }}&id={{ id }}
    :请求方式: Get
    :请求参数:无
    :返回数据: citygroups 城市分组列表,cities 所有城市(列表)
    :[[id,name],[id,name],....]

    :请求方式:Post
    :请求参数:cms_category_itembean字段(input name)
    """
    channel_id = request.GET.get('channel')
    id = request.GET.get("id")
    c, v, t = getCVT(channel_id)
    # 根据类型得到名称
    text = get_nav_text(str(t))
    categoryitembean = CmsCategoryItembean.objects.get(id=id)
    if request.method == "POST":
        postcopys = request.POST.copy()
        content = op_content_save(postcopys)
        postcopys["content"] = json.dumps(content, ensure_ascii=False)
        form = CmsCategoryItembeanForm(postcopys, instance=categoryitembean)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_SECOND_CATEGORY,
                         table_name='CmsCategoryItembean',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(
                reverse("second_category") + "?t=%d&c=%s&v=%s" % (t, c, v))
    else:
        form = CmsCategoryItembeanForm(instance=categoryitembean)
    errors, fields = format_form(form)
    fields = op_content_edit(fields)
    citygroups = get_city_group()
    cities = get_city_list()
    return render_to_response(template_name, {
        "fields": fields,
        "errors": errors,
        "citygroups": citygroups,
        "cities": cities,
        "t": t,
        "c": c,
        "v": v,
        "text": text,
        "channel": channel_id,
        "id": id,
    },
                              context_instance=RequestContext(request))
示例#18
0
def edit_content_stream(request, template_name):
    """
    编辑 内容流
    url :{% url 'new_content_stream' %}?channel={{ channel }}&id={{ id }}
    :请求方式:Get
    :请求参数:channel,id(内容流id)
    :返回数据:form 表单 open_type 类别(actions 动作 cities 城市列表 citygroups 城市分组)(和之前一致)
    :例如:open_type [[0,"服务"],[1,"商品"]]

    :请求方式:Post
    :请求参数:input name 和数据库表cms_streamcontentbeans字段名称一致(除了id)
    :注意: 其他没有在input展示的要搞个input-hidden value = 0
    """
    channel_id = request.GET.get('channel')
    id = request.GET.get("id")
    c, v, t = getCVT(channel_id)
    # 根据类型得到名称
    text = get_nav_text(str(t))
    if request.method == 'POST':
        beans = CmsStreamcontentbeans.objects.get(id=id)
        form = StreamcontentbeansForm(request.POST, instance=beans)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_STREAM,
                         table_name='CmsStreamcontentbeans',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X", time.localtime())).save()
            return HttpResponseRedirect(reverse("streams") + "?t=%d&c=%s&v=%s" % (t, c, v))
    else:
        beans = CmsStreamcontentbeans.objects.get(id=id)
        form = CmsAdsForm(instance=beans)
    actions = get_actions_select()
    cities = get_city_list()
    citygroups = get_city_group()
    errors, fields = format_form(form)
    return render_to_response(template_name, {
        "form": form,
        "open_type": open_type,
        "actions": actions,
        "cities": cities,
        "citygroups": citygroups,
        "fields": fields,
        "errors": errors,
        "t": t,
        "c": c,
        "v": v,
        "text": text,
        "channel": channel_id,
        "id": id
    }, context_instance=RequestContext(request))
示例#19
0
文件: images.py 项目: cash2one/pt
def del_image(request):
    data = request.POST.copy()
    delete_list = data.getlist("del_list[]")
    for image_url in delete_list:
        delete_image_obj = CmsImageInfo.objects.get(image_url=image_url)
        if CMS_CHECK_ON:
            CmsCheck(module=CmsModule.MAIN_IMAGE,
                     table_name='CmsImageInfo',
                     data_id=delete_image_obj.id,
                     op_type=CheckOpType.DELETE).save()
        delete_image_obj.delete()
    return HttpResponse(0)
示例#20
0
def edit_second_category(request, template_name):
    """
    编辑二级分类
    url :{% url 'sc_edit_second_category' %}?channel={{ channel }}&id={{ id }}
    :请求方式: Get
    :请求参数:channel,id
    :返回数据:form 表单 scenes 场景列表 services 服务列表
    :例如:scenes 场景列表 和之前一样 streams_type = [[1,"活动"],[2,"服务"],[3,"商品"],[4,"搜索"]]

    :请求方式:Post
    :请求参数:
    """
    channel_id = request.GET.get('channel')
    id = request.GET.get("id")
    category_item = CmsCategoryItem.objects.get(id=id)
    c, v, t = getCVT(channel_id)
    # 根据类型得到名称
    text = get_nav_text(str(t))
    if request.method == 'POST':
        form = CmsCategoryItemForm(request.POST, instance=category_item)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(channel_id=channel_id,
                         module=CmsModule.CONFIG_SECOND_CATEGORY,
                         table_name='CmsCategoryItem',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(
                reverse("second_category") + "?t=%d&c=%s&v=%s" % (t, c, v))
    else:
        form = CmsCategoryItemForm(instance=category_item)
    scenes = get_scenes()
    services = get_services()
    errors, fields = format_form(form)
    return render_to_response(template_name, {
        "scenes": scenes,
        "services": services,
        "fields": fields,
        "errors": errors,
        "t": t,
        "c": c,
        "v": v,
        "text": text,
        "channel": channel_id,
        "id": id
    },
                              context_instance=RequestContext(request))
示例#21
0
文件: category.py 项目: cash2one/pt
def edit_category_first(request, template_name):
    id = request.GET.get("id")
    category = CmsNaviCategory.objects.get(id=id)
    if request.method == "POST":
        form = NaviCategoryForm(request.POST, instance=category)
        if form.is_valid():
            form.save()
            cate_group_id = request.POST.get("cate_group_id")
            if CmsViewGroupCategory.objects.filter(category=category):
                ins_viewgroupcate = CmsViewGroupCategory.objects.get(
                    category=category)
                ins_viewgroupcate.group_id = cate_group_id
                ins_viewgroupcate.save()
            else:
                CmsViewGroupCategory(category=category,
                                     group_id=cate_group_id).save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_CATEGORY,
                         table_name='CmsNaviCategory',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse('category'))
    else:

        form = NaviCategoryForm(instance=category)
    errors, fields = format_form(form)
    if CmsViewGroupCategory.objects.filter(category=category):
        ins_viewgroupcate = CmsViewGroupCategory.objects.get(category=category)
        fields["cate_group_id"] = json.dumps(ins_viewgroupcate.group_id)
    scenes = get_scenes()
    actions = get_actions_select()
    citygroups = get_city_group()
    cities = get_city_list()
    cate_groups = CmsCategoryGroup.objects.all()
    return render_to_response(template_name, {
        "scenes": scenes,
        "actions": actions,
        "citygroups": citygroups,
        "cities": cities,
        "show_style_list": show_style_list,
        "id": id,
        "fields": fields,
        "errors": errors,
        "cate_groups": cate_groups,
        "CATE_TYPE": CATE_TYPE
    },
                              context_instance=RequestContext(request))
示例#22
0
def edit_coupons(request, template_name):
    """
    编辑优惠券
    url :{% url 'edit_coupons' %}?id={{ id }}
    :请求方式: Get
    :请求参数:id(优惠券id)
    :返回数据:scenes 场景列表 citygroups 城市分组列表,cities 所有城市(列表)
    :[[id,name],[id,name],....]

    :请求方式:Post
    :请求参数:数据库字段(input name)
    """
    id = request.GET.get("id")
    oCmsCoupon = CmsCoupon.objects.get(id=id)
    if request.method == "POST":
        form = CouponsForm(request.POST, instance=oCmsCoupon)
        form.data['start'] = make_timestamp(form.data['start'])
        form.data['end'] = make_timestamp(form.data['end'])
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_COUPON,
                         table_name='CmsCoupon',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse("coupons"))
    else:
        form = CouponsForm(instance=oCmsCoupon)
    errors, fields = format_form(form)
    if 'start' in fields.keys():
        fields['start'] = json.dumps(timestamp2str(fields['start']))
    if 'end' in fields.keys():
        fields['end'] = json.dumps(timestamp2str(fields['end']))
    scenes = get_scenes()
    citygroups = get_city_group()
    cities = get_city_list()
    return render_to_response(template_name, {
        "scenes": scenes,
        "citygroups": citygroups,
        "cities": cities,
        "errors": errors,
        "fields": fields,
        "id": id
    },
                              context_instance=RequestContext(request))
示例#23
0
def exchange_obj(classobj1,
                 id1,
                 classobj2,
                 id2,
                 channel_id,
                 module,
                 request,
                 word1="location",
                 word2="location"):
    obj1 = classobj1.objects.get(id=id1)
    obj2 = classobj2.objects.get(id=id2)
    value1 = getattr(obj1, word1)
    value2 = getattr(obj2, word2)
    setattr(obj1, word1, value2)
    setattr(obj2, word2, value1)
    obj1.save()
    obj2.save()
    if CMS_CHECK_ON:
        check = CmsCheck(channel_id=channel_id,
                         module=module,
                         table_name=classobj1.__name__,
                         data_id=id1,
                         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()
        check = CmsCheck(channel_id=channel_id,
                         module=module,
                         table_name=classobj2.__name__,
                         data_id=id2,
                         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()
示例#24
0
def new_specialtopic(request, template_name):
    """
    新建专题
    url :{% url 'new_specialtopic' %}
    :请求方式: Get
    :请求参数:无
    :返回数据:scenes 场景列表 citygroups 城市分组列表,cities 所有城市(列表) actions 动作列表 open_type 类型
    :[[id,name],[id,name],....]

    :请求方式:Post
    :请求参数:数据库字段(input name)
    """
    if request.method == "POST":
        form = SpecialTopicForm(request.POST)
        if form.is_valid():
            ospecialtopic = form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_TOPIC,
                         table_name='CmsSpecialTopic',
                         data_id=ospecialtopic.id,
                         op_type=CheckOpType.NEW,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse("specialtopics"))
    else:
        form = SpecialTopicForm()
    errors, fields = format_form(form)
    citygroups = get_city_group()
    actions = get_actions_select()
    cities = get_city_list()
    scenes = get_scenes()
    return render_to_response(template_name, {
        "fields": fields,
        "errors": errors,
        "citygroups": citygroups,
        "actions": actions,
        "cities": cities,
        "scenes": scenes,
        "open_type": open_type,
    },
                              context_instance=RequestContext(request))
示例#25
0
def edit_version(request):
    try:
        type_id = request.POST["type_id"]
        old_ver = request.POST["old_ver"]
        new_ver = request.POST["new_ver"]
        ver_obj = CmsChannelsAppVersion.objects.get(type_id=type_id,
                                                    app_version=old_ver)
        ver_obj.app_version = new_ver
        ver_obj.save()
        if CMS_CHECK_ON:
            CmsCheck(module=CmsModule.MAIN_CHANNEL,
                     table_name='CmsChannelsAppVersion',
                     data_id=ver_obj.id,
                     op_type=CheckOpType.EDIT,
                     alter_person=request.user.username,
                     alter_date=time.strftime("%Y-%m-%d %X",
                                              time.localtime())).save()
        return HttpResponse(0)
    except:
        return HttpResponse(1)
示例#26
0
文件: category.py 项目: cash2one/pt
def edit_category_second(request, template_name):
    id = request.GET.get("id")
    if request.method == "POST":
        goods = CmsNaviCategory.objects.get(id=id)
        form = NaviCategoryForm(request.POST, instance=goods)
        if form.is_valid():
            form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_CATEGORY,
                         table_name='CmsNaviCategory',
                         data_id=id,
                         op_type=CheckOpType.EDIT,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse('category'))
    else:
        navicategory = CmsNaviCategory.objects.get(id=id)
        form = NaviCategoryForm(instance=navicategory)
    errors, fields = format_form(form)
    scenes = get_scenes()
    actions = get_actions_select()
    citygroups = get_city_group()
    cities = get_city_list()
    cate2s = get_first_categories()
    return render_to_response(
        template_name,
        {
            "scenes": scenes,
            "actions": actions,
            "goods_form": form,
            "citygroups": citygroups,
            "show_style_list": show_style_list,
            "cities": cities,
            "id": id,
            "fields": fields,
            "errors": errors,
            "cate2s": cate2s,
            # "first_categories":first_categories
        },
        context_instance=RequestContext(request))
示例#27
0
def delete_specialtopic(request):
    """
    删除内容库的专题,内容库的专题会删除掉,首页专题会删掉,发现页专题is_deleted=1
    :param request:
    :return:
    """
    id = request.POST.get('id')
    topic = CmsSpecialTopic.objects.get(id=id)
    objs = CmsViewFindTopic.objects.filter(topic_id=id)
    for obj in objs:
        obj.is_deleted = 1
        obj.delete_time = time.timezone.now()
        obj.save()
        if CMS_CHECK_ON:
            check = CmsCheck(module=CmsModule.MAIN_TOPIC,
                             table_name="CmsViewFindTopic",
                             data_id=id,
                             op_type=CheckOpType.EDIT,
                             status=CheckStatu.WAIT_SUBMIT,
                             is_show=0,
                             alter_person=request.user.username,
                             alter_date=time.strftime("%Y-%m-%d %X",
                                                      time.localtime()))
            check.save()
    if CMS_CHECK_ON:
        check = CmsCheck(module=CmsModule.MAIN_TOPIC,
                         table_name="CmsSpecialTopic",
                         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()
    topic.delete()
    return HttpResponse(0)
示例#28
0
def new_action(request, template_name):
    if request.method == "POST":
        form = ActionForm(request.POST)
        if form.is_valid():
            actions = form.save()
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_ACTION,
                         table_name='CmsActions',
                         data_id=actions.id,
                         op_type=CheckOpType.NEW,
                         alter_person=request.user.username,
                         alter_date=time.strftime("%Y-%m-%d %X",
                                                  time.localtime())).save()
            return HttpResponseRedirect(reverse('actions'))
    else:
        form = ActionForm()
    errors, fields = format_form(form)
    return render_to_response(template_name, {
        "errors": errors,
        "fields": fields
    },
                              context_instance=RequestContext(request))
示例#29
0
文件: images.py 项目: cash2one/pt
def new_image(request, template_name):
    if request.method == 'POST':
        postdata = request.POST.copy()
        try:
            oCmsImageInfos = CmsImageInfo.objects.get_or_create(
                image_name=postdata['image_name'])
            oCmsImageInfo = oCmsImageInfos[0]
            oCmsImageInfo.image_url = postdata['image_url']
            oCmsImageInfo.image_category = postdata['image_category']
            oCmsImageInfo.save()
            # oCmsImageInfo.save(using="online")
            if CMS_CHECK_ON:
                CmsCheck(module=CmsModule.MAIN_IMAGE,
                         table_name='CmsImageInfo',
                         data_id=oCmsImageInfo.id,
                         op_type=CheckOpType.NEW
                         if oCmsImageInfos[1] else CheckOpType.EDIT).save()
        except Exception as ex:
            print(ex)
        return HttpResponseRedirect(reverse('images'))
    else:
        return render_to_response(template_name)
示例#30
0
def channel_op(request):
    if request.method == 'POST':
        data = request.POST.copy()
        error = ""
        for key in data:
            if data[key] == "":
                error += key + " is null \n"
        if error:
            return HttpResponse(error)
        else:
            try:
                config_items = json.loads(request.POST.get("config_items"))
                channel_op_type = request.POST.get("channel_op_type")
                source_channel_id = request.POST.get("source_channel_id")
                target_channel_list = json.loads(
                    request.POST.get("target_channel_list"))
                config_items = sorted(config_items)
                op_channel = OpChannel(source_channel_id)
                for target_channel_id in target_channel_list:
                    # 清空目标渠道的数据
                    DelChannel.del_config_channel(target_channel_id,
                                                  config_items)
                    ocms_channel_channel = op_channel.copy_asso(
                        target_channel_id,
                        config_items=config_items,
                        channel_op_type=channel_op_type)
                    if CMS_CHECK_ON:
                        CmsCheck(module=CmsModule.MAIN_CHANNEL,
                                 table_name='CmsChannelChannel',
                                 data_id=ocms_channel_channel.id,
                                 op_type=CheckOpType.NEW,
                                 alter_person=request.user.username,
                                 alter_date=time.strftime(
                                     "%Y-%m-%d %X", time.localtime())).save()
                return HttpResponse(0)
            except Exception as ex:
                return HttpResponse(ex.args[0])