def room_edit(request, id): status = check_auth(request, "edit_idc") if not status: return render_to_response('default/error_auth.html', locals(), context_instance=RequestContext(request)) room = IDC.objects.get(id=id) if request.method == 'POST': uf = Engine_RoomForm(request.POST, instance=room) if uf.is_valid(): uf.save() return HttpResponseRedirect("/assets/server/room/list/") uf = Engine_RoomForm(instance=room) return render_to_response('assets/server_room_add.html', locals(), context_instance=RequestContext(request))
def add_room(request): """ 添加机房 """ status = check_auth(request, "add_idc") if not status: return render_to_response('default/error_auth.html', locals(), context_instance=RequestContext(request)) server_type = Project.objects.all() if request.method == 'POST': uf = Engine_RoomForm(request.POST) if uf.is_valid(): uf.save() return HttpResponseRedirect("/assets/server/room/list/") else: uf = Engine_RoomForm() return render_to_response('assets/server_room_add.html', locals(), context_instance=RequestContext(request))