def editRoleView(request, ID): role_info = Role.objects.get(id=ID) if request.method == 'POST': form = RoleListForm(request.POST, instance=role_info) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('rolelisturl')) else: role_form = RoleListForm(instance=role_info) context_dict = { 'form': role_form, 'ID': ID, } return render(request, 'common/editrole.html', context_dict)
def role_add(request): temp_name = "accounts/accounts-header.html" if request.method == "POST": form = RoleListForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('role_list')) else: form = RoleListForm() kwvars = { 'temp_name': temp_name, 'form': form, 'request': request, } return render(request, 'accounts/role_add.html', kwvars)
def role_edit(request, ids): iRole = RoleList.objects.get(id=ids) temp_name = "accounts/accounts-header.html" if request.method == "POST": form = RoleListForm(request.POST,instance=iRole) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('role_list')) else: form = RoleListForm(instance=iRole) kwvars = { 'temp_name': temp_name, 'ids': ids, 'form': form, 'request': request, } return render(request, 'accounts/role_edit.html', kwvars)
def role_edit(request, ids): iRole = RoleList.objects.get(id=ids) temp_name = "accounts/accounts-header.html" if request.method == "POST": form = RoleListForm(request.POST, instance=iRole) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('role_list')) else: form = RoleListForm(instance=iRole) kwvars = { 'temp_name': temp_name, 'ids': ids, 'form': form, 'request': request, } return render(request, 'accounts/role_edit.html', kwvars)
def role_edit(request, ids): iRole = RoleList.objects.get(id=ids) # print "the iRole is:%s" % iRole temp_name = "skaccounts/accounts-header.html" if request.method == "POST": form = RoleListForm(request.POST, instance=iRole) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('role_list')) else: form = RoleListForm(instance=iRole) # print "the form is:%s" % form kwvars = { 'temp_name': temp_name, 'ids': ids, 'form': form, 'request': request, } return render_to_response('skaccounts/role_edit.html', kwvars, RequestContext(request))