Ejemplo n.º 1
0
def tenant_edit(request):
    """
    Tenant edit view
    """
    header_title, path1, path2 = u'编辑租户', u'资产管理', u'编辑租户'
    tenant_id = request.GET.get('id', '')
    tenant = get_object(Tenant_info, id=tenant_id)
    if request.method == 'POST':
        tenant_form  = TenantForm(request.POST, instance=tenant)
        if tenant_form.is_valid():
            tenant_form.save()
            return HttpResponseRedirect(reverse('tenant_list'))
    else:
        tenant_form = TenantForm(instance=tenant)
        print tenant_form
        return my_render('jasset/tenant_edit.html', locals(), request)
Ejemplo n.º 2
0
def tenant_add(request):
    """
    Tenant info  add view
    """
    header_title, path1, path2 = u'添加租户', u'资产管理', u'添加租户'
    if request.method == 'POST':
        tenant_form = TenantForm(request.POST)
        if tenant_form.is_valid():
            tenant_name = tenant_form.cleaned_data['tenant_name']
            if IDC.objects.filter(name=tenant_name):
                emg = u'添加租户失败, 此 %s 已存在!' % tenant_name
                return my_render('jasset/tenant_add.html', locals(), request)
            else:
                tenant_form.save()
                smg = u'IDC: %s添加成功' % tenant_name
            return HttpResponseRedirect(reverse('tenant_list'))
    else:
        Tenant_Form = TenantForm()
    return my_render('jasset/tenant_add.html', locals(), request)