def AddPermission(request): form = PermissionListForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('listpermissionurl')) else: form = PermissionListForm() kwvars = { 'form': form, 'request': request, } return render_to_response('UserManage/permission.add.html', kwvars, RequestContext(request))
def EditPermission(request, ID): iPermission = PermissonList.objects.get(id=ID) if request.method == "POST": form = PermissionListForm(request.POST, instance=iPermission) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("listpermissionurl")) else: form = PermissionListForm(instance=iPermission) kwvars = { 'ID': ID, 'form': form, 'request': request, } return render_to_response('UserManage/permission.edit.html', kwvars, RequestContext(request))