Exemplo n.º 1
0
def domainHome(request):
    domain = getDomainObj(request)
    if not domain:
        return HttpResponseRedirect(reverse('domain_home'))
    form = DomainBasicForm(domain_id=domain.id, request=request)
    return render(request,
                  "domain/static.html",
                  context={
                      "page": "basic",
                      "form": form,
                      "domain": domain,
                  })
Exemplo n.º 2
0
def domainBasic(request):
    domain, domain_list = getDomainObj(request)
    if not domain:
        return HttpResponseRedirect(reverse('domain_home'))
    form = DomainBasicForm(domain_id=domain.id)
    if request.method == "POST":
        form = DomainBasicForm(domain_id=domain.id, post=request.POST)
        if form.is_valid():
            form.save()
    return render(request,
                  "domain/include/static_basic.html",
                  context={
                      "page": "basic",
                      "form": form,
                      "domain_list": domain_list,
                      "domain": domain,
                  })
Exemplo n.º 3
0
def domainPublicList(request):
    domain = getDomainObj(request)
    if not domain:
        return HttpResponseRedirect(reverse('domain_home'))
    domain_id = domain.id
    form = DomainBasicForm(domain_id=domain.id, request=request)
    htmlTemplate = "domain/include/static_public_list.html"
    contextData = {}
    if request.method == "POST":
        action = request.POST.get('action', '')
        #删除某行
        if action == 'delete':
            id = request.POST.get('id', '')
            WmCustomerInfo.objects.get(id=id).delete()

        #删除所有
        if action == 'deleteall':
            ids = request.POST.get('ids', '')
            ids = ids.split(',')
            WmCustomerInfo.objects.filter(id__in=ids).delete()

        if action == 'delete_type':
            id = request.POST.get('id', '')
            WmCustomerCate.objects.get(id=id).delete()
            htmlTemplate = "domain/include/static_public_type.html"

        if action == 'delete_type_all':
            ids = request.POST.get('ids', '')
            ids = ids.split(',')
            WmCustomerCate.objects.filter(id__in=ids).delete()
            htmlTemplate = "domain/include/static_public_type.html"

        #点击查看某个按钮
        if action == "view":
            button = request.POST.get('button', '')
            if button == "add":
                form = DomainPublicInputForm(domain_id, request=request)
                htmlTemplate = "domain/include/static_public_list_mdf.html"

            elif button == "mdf":
                mdf_id = request.POST.get('id', '')
                instance = WmCustomerInfo.objects.filter(id=mdf_id).first()
                form = DomainPublicInputForm(domain_id,
                                             instance=instance,
                                             request=request)
                htmlTemplate = "domain/include/static_public_list_mdf.html"
                contextData["id"] = mdf_id

            elif button == "import_add":
                form = DomainPublicImportForm(domain_id,
                                              "import_add",
                                              request=request)
                htmlTemplate = "domain/include/static_public_list_import_add.html"
            elif button == "import_del":
                form = DomainPublicImportForm(domain_id,
                                              "import_del",
                                              request=request)
                htmlTemplate = "domain/include/static_public_list_import_del.html"

            elif button == "type_list":
                htmlTemplate = "domain/include/static_public_type.html"

            elif button == "type_add":
                form = DomainPublicTypeForm(domain_id, request=request)
                htmlTemplate = "domain/include/static_public_type_mdf.html"

            elif button == "type_mdf":
                mdf_id = request.POST.get('id', '')
                contextData["id"] = mdf_id
                instance = WmCustomerCate.objects.filter(id=mdf_id).first()
                form = DomainPublicTypeForm(domain_id,
                                            instance=instance,
                                            request=request)
                htmlTemplate = "domain/include/static_public_type_mdf.html"

        #点击保存某个按钮的输入
        if action == "save":
            button = request.POST.get('button', '')
            if button in ("add", "mdf"):
                mdf_id = request.POST.get('id', '')
                if mdf_id:
                    instance = WmCustomerInfo.objects.filter(id=mdf_id).first()
                    contextData["id"] = mdf_id
                else:
                    instance = None
                form = DomainPublicInputForm(domain_id,
                                             instance=instance,
                                             post=request.POST,
                                             request=request)
                if form.is_valid():
                    form.save()
                    htmlTemplate = "domain/include/static_public_list.html"
                else:
                    htmlTemplate = "domain/include/static_public_list_mdf.html"

            elif button == "import_add":
                form = DomainPublicImportForm(domain_id,
                                              "import_add",
                                              post=request.POST,
                                              request=request)
                if not form.checkSave():
                    htmlTemplate = "domain/include/static_public_list_import_add.html"

            elif button == "import_del":
                form = DomainPublicImportForm(domain_id,
                                              "import_del",
                                              post=request.POST,
                                              request=request)
                if not form.checkSave():
                    htmlTemplate = "domain/include/static_public_list_import_del.html"

            elif button in ("type_add", "type_mdf"):
                mdf_id = request.POST.get('id', '')
                if mdf_id:
                    instance = WmCustomerCate.objects.filter(id=mdf_id).first()
                    contextData["id"] = mdf_id
                else:
                    instance = None
                form = DomainPublicTypeForm(domain_id,
                                            instance=instance,
                                            post=request.POST,
                                            request=request)
                if form.is_valid():
                    form.save()
                    htmlTemplate = "domain/include/static_public_type.html"
                else:
                    htmlTemplate = "domain/include/static_public_type_mdf.html"

    domain_list = Domain.objects.all()
    contextData.update({
        "page": "public",
        "form": form,
        "domain": domain,
        "domain_list": domain_list,
    })
    return render(request, htmlTemplate, context=contextData)