Пример #1
0
def new_goods(request):
    """
     分类导航 新建商品
    :请求方式:ajax Post
    :请求URL:{% url 'category_pages_services_new_goods' %}
    :请求参数:goods_id  navicategories_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:
            goods_id = request.POST.get("goods_id")
            # 导航表ID
            navicategories_id = request.POST.get("navicategories_id")
            navicategories = CmsNavicategories.objects.get(
                id=navicategories_id)
            channel_id = request.POST.get("channel_id")
            try:
                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_PAGE,
                             table_name='CmsGoods',
                             data_id=goods.id,
                             op_type=CheckOpType.NEW,
                             remark="在id为%s的分类组里面增加了名称为%s的商品" %
                             (CheckManager.wrap_style(navicategories_id),
                              CheckManager.wrap_style(goods.name)),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
                ocmsnavicatesgoods = CmsNavicatesGoods(cate=navicategories,
                                                       goods=goods)
                ocmsnavicatesgoods.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_PAGE,
                             table_name='CmsNavicatesGoods',
                             data_id=ocmsnavicatesgoods.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:
                if 'Duplicate entry' in ex.args[0]:
                    return HttpResponse(1)
                return HttpResponse(ex.args[0])
            return HttpResponse(0)
Пример #2
0
def new_category(request):
    """
    分类页服务  新建分类(二级分类)
    :请求方式:ajax Post
    :请求URL:{% url 'category_pages_services_new_category' %}
    :请求参数:navicategories_id(分类组表id)  category_id(分类表id)
    :直接插入关系表 导航与分类关系表 cms_navicates_category
    :类型 :传数字
    返回: 成功: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:
                category_id = request.POST.get("category_id")
                # 分类组ID
                navicategories_id = request.POST.get("navicategories_id")
                channel_id = request.POST.get("channel_id")
                c, v, t = getCVT(channel_id)
                navicategories = CmsNavicategories.objects.get(
                    id=navicategories_id)
                category = CmsNaviCategory.objects.get(id=category_id)
                oCmsNavicatesCategory = CmsNavicatesCategory(
                    cate=navicategories, category=category)
                oCmsNavicatesCategory.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_PAGE,
                             table_name='CmsNavicatesCategory',
                             data_id=oCmsNavicatesCategory.id,
                             op_type=CheckOpType.NEW,
                             remark="在id为%s的分类组里面增加了名称为%s的分类" %
                             (CheckManager.wrap_style(navicategories_id),
                              CheckManager.wrap_style(category.name)),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
            except Exception as ex:
                if 'Duplicate entry' in ex.args[0]:
                    return HttpResponse(1)
                return HttpResponse(ex.args[0])
            return HttpResponse(0)
Пример #3
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)
Пример #4
0
def new_common_service(request):
    """
     新建服务导航 服务
    :请求方式:ajax Post
    :请求参数:service_id  channel_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:
            service_id = request.POST.get("service_id")
            channel_id = request.POST.get("channel_id")
            services = CmsServices.objects.get(id=service_id)
            services.type = 1
            services.parent_id = service_id
            services.id = None
            services.save()
            try:
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_COMMON_SERVICES,
                             table_name='CmsServices',
                             data_id=services.id,
                             op_type=CheckOpType.NEW,
                             remark="增加了名称为%s的服务" %
                             (CheckManager.wrap_style(services.name), ),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
                oCmsViewService = CmsViewService(
                    service_id=services.id,
                    channel=CmsChannels.objects.get(id=channel_id),
                    open_type=0)
                oCmsViewService.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_COMMON_SERVICES,
                             table_name='CmsViewService',
                             data_id=oCmsViewService.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, services.id,
                              CONFIG_ITEMS.COMMON_SERVICES, request)
            except Exception as ex:
                if 'Duplicate entry' in ex.args[0]:
                    return HttpResponse(1)
                return HttpResponse(ex.args[0])
            return HttpResponse(0)
Пример #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_coupons(request):
    """
    配置库:新建优惠券
    :请求方式:ajax Post
    :请求URL:{% url 'new_config_coupons' %}
    :请求参数:coupons_id  channel_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:
            coupons_id = request.POST.get("coupons_id")
            channel_id = request.POST.get("channel_id")
            try:
                coupons = CmsCoupon.objects.get(id=coupons_id)
                coupons.parent_id = coupons_id
                coupons.id = None
                coupons.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_COUPON,
                             table_name='CmsCoupon',
                             data_id=coupons.id,
                             op_type=CheckOpType.NEW,
                             remark="增加名称为%s的优惠券" %
                             (CheckManager.wrap_style(coupons.name), ),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
                oCmsViewCoupon = CmsViewCoupon(
                    coupon=coupons,
                    channel=CmsChannels.objects.get(id=channel_id))
                oCmsViewCoupon.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_COUPON,
                             table_name='CmsViewCoupon',
                             data_id=oCmsViewCoupon.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, coupons.id, CONFIG_ITEMS.COUPONS,
                              request)
            except Exception as ex:
                return HttpResponse(ex.args[0])
            return HttpResponse(0)
Пример #7
0
def new_service(request):
    """
    猜你喜欢 添加服务
    :请求方式:ajax Post
    :请求URL:{% url 'likes_new_service' %}
    :请求参数:service_id  like_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:
            service_id = request.POST.get("service_id")
            like_id = request.POST.get("like_id")
            channel_id = request.POST.get("channel_id")
            try:
                service = CmsServices.objects.get(id=service_id)
                service.parent_id = service_id
                service.id = None
                service.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_LIKE,
                             table_name='CmsServices',
                             data_id=service.id,
                             op_type=CheckOpType.NEW,
                             remark="增加了名称为%s的服务" %
                             (CheckManager.wrap_style(service.name), ),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
                oCmsLikesServices = CmsLikesServices(
                    service=service, like=CmsLikes.objects.get(id=like_id))
                oCmsLikesServices.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_LIKE,
                             table_name='CmsLikesServices',
                             data_id=oCmsLikesServices.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 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)
Пример #9
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)
Пример #10
0
def new_foundpage_specialtopic(request):
    """
    配置库: 新增发现页专题
    :请求方式:ajax Post
    :请求URL:{% url 'new_foundpage_specialtopic' %}
    :请求参数:specialtopic_id  channel_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:
                specialtopic_id = request.POST.get("specialtopic_id")
                channel_id = request.POST.get("channel_id")
                c, v, t = getCVT(channel_id)
                ospecialtopic = CmsSpecialTopic.objects.get(id=specialtopic_id)
                oCmsViewFindTopic = CmsViewFindTopic(
                    channel_id=channel_id,
                    topic_id=specialtopic_id,
                    create_time=time.timezone.now(),
                    update_time=time.timezone.now())
                oCmsViewFindTopic.save()
                if CMS_CHECK_ON:
                    CmsCheck(channel_id=channel_id,
                             module=CmsModule.CONFIG_FOUNDPAGE,
                             table_name='CmsViewFindTopic',
                             data_id=oCmsViewFindTopic.id,
                             op_type=CheckOpType.NEW,
                             remark="增加标题为%s的发现页专题" %
                             (CheckManager.wrap_style(ospecialtopic.title), ),
                             alter_person=request.user.username,
                             alter_date=time.strftime(
                                 "%Y-%m-%d %X", time.localtime())).save()
                new_associate(channel_id, specialtopic_id,
                              CONFIG_ITEMS.FOUNDPAGE, request)
                # jpush_foundpage(CmsChannels.objects.get(id=channel_id).channel_no,v,oCmsViewFindTopic.id,ospecialtopic.title,ospecialtopic.city)
                push_foundpage(channel_id, specialtopic_id)
                return HttpResponse(0)
            except Exception as ex:
                if 'Duplicate entry' in ex.args[0]:
                    return HttpResponse(1)
                return HttpResponse(ex.args[0])
Пример #11
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)
Пример #12
0
def new_common_category(request):
    """
    常用服务  新建常用分类
    :请求方式:ajax Post
    :请求URL:{% url 'new_common_category' %}
    :请求参数:category_id  channel_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:
            # navicategory.parent_id = category_id
            # navicategory.id = None
            # navicategory.save()
            try:
                category_id = request.POST.get("category_id")
                channel_id = request.POST.get("channel_id")
                navicategory = CmsNaviCategory.objects.get(id=category_id)
                if navicategory.fatherid != 0:
                    group_name = CmsViewGroupCategory.objects.get(
                        category_id=navicategory.fatherid).group.name
                else:
                    group_name = CmsViewGroupCategory.objects.get(
                        category=navicategory).group.name
                if group_name == CategoryGroupType.daojia:
                    open_type = 6
                    if navicategory.fatherid == 0:
                        open_type = 5
                else:
                    open_type = 4
                    if navicategory.fatherid == 0:
                        open_type = 3
                oCmsViewService = CmsViewService(
                    service_id=category_id,
                    channel=CmsChannels.objects.get(id=channel_id),
                    open_type=open_type)
                oCmsViewService.save()
                if CMS_CHECK_ON:
                    CmsCheck(
                        channel_id=channel_id,
                        module=CmsModule.CONFIG_COMMON_SERVICES,
                        table_name='CmsViewService',
                        data_id=oCmsViewService.id,
                        op_type=CheckOpType.NEW,
                        remark="增加了名称为%s的%d级分类" % (CheckManager.wrap_style(
                            navicategory.name), open_type - 2),
                        alter_person=request.user.username,
                        alter_date=time.strftime("%Y-%m-%d %X",
                                                 time.localtime())).save()
                new_associate(channel_id,
                              navicategory.id,
                              CONFIG_ITEMS.COMMON_SERVICES,
                              request,
                              open=open_type)
            except Exception as ex:
                if 'Duplicate entry' in ex.args[0]:
                    return HttpResponse(1)
                return HttpResponse(ex.args[0])
            return HttpResponse(0)