Ejemplo n.º 1
0
def idc_add(request):
    if request.method == "POST":
        idc_form = IdcForm(request.POST)
        if idc_form.is_valid():
            idc_form.save()
            tips = u"增加成功!"
            display_control = ""
        else:
            tips = u"增加失败!"
            display_control = ""
        return render(request, "cmdb/idc_base.html", locals())
    else:
        display_control = "none"
        idc_form = IdcForm()
        return render(request, "cmdb/idc_base.html", locals())
Ejemplo n.º 2
0
def group_add(request):
    temp_name = "cmdb/cmdb-header.html"
    if request.method == "POST":
        group_form = GroupForm(request.POST)
        if group_form.is_valid():
            group_form.save()
            tips = u"增加成功!"
            display_control = ""
        else:
            tips = u"增加失败!"
            display_control = ""
        # return render(request, "cmdb/group_add.html", locals())
        return redirect('group_add')
    else:
        display_control = "none"
        group_form = GroupForm()
        idc_form = IdcForm()
        return render(request, "cmdb/group_add.html", locals())
Ejemplo n.º 3
0
def idc_edit(request, idc_id):
    project = Idc.objects.get(id=idc_id)
    if request.method == 'POST':
        form = IdcForm(request.POST, instance=project)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('idc'))
    else:
        form = IdcForm(instance=project)
    display_control = "none"
    results = {
        'idc_form': form,
        'idc_id': idc_id,
        'request': request,
        'display_control': display_control,
    }
    return render(request, 'cmdb/idc_base.html', results)