def new(request): if request.method == 'POST': # If the form has been submitted... form = GroupForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass g = form.save() messages.add_message(request, messages.SUCCESS, 'Group created') return HttpResponseRedirect('/intranet/group/manage/%d'%g.id) # Redirect after POST else: form = GroupForm() # An unbound form return render_to_response('intranet/group_manager/form.html',{ 'form': form, "section":"intranet", "page":'group', "page_title":"Create new Group" },context_instance=RequestContext(request))
def edit(request,id): g = Group.objects.get(id=id) forms = GroupMemberFormSet(instance=g) if request.method == 'POST': # If the form has been submitted... form = GroupForm(request.POST,instance=g) # A form bound to the POST data if form.is_valid(): # All validation rules pass form.save() messages.add_message(request, messages.SUCCESS, 'Group saved') return HttpResponseRedirect('/intranet/group') # Redirect after POST else: form = GroupForm(instance=g) return render_to_response('intranet/group_manager/form.html',{ "form":form, "section":"intranet", "page":'group', "page_title":"Edit Group", },context_instance=RequestContext(request))
def edit(request, id): g = Group.objects.get(id=id) forms = GroupMemberFormSet(instance=g) if request.method == 'POST': # If the form has been submitted... form = GroupForm(request.POST, instance=g) # A form bound to the POST data if form.is_valid(): # All validation rules pass form.save() messages.add_message(request, messages.SUCCESS, 'Group saved') return HttpResponseRedirect( '/intranet/group') # Redirect after POST else: form = GroupForm(instance=g) return render_to_response('intranet/group_manager/form.html', { "form": form, "section": "intranet", "page": 'group', "page_title": "Edit Group", }, context_instance=RequestContext(request))
def new(request): if request.method == 'POST': # If the form has been submitted... form = GroupForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass g = form.save() messages.add_message(request, messages.SUCCESS, 'Group created') return HttpResponseRedirect('/intranet/group/manage/%d' % g.id) # Redirect after POST else: form = GroupForm() # An unbound form return render_to_response('intranet/group_manager/form.html', { 'form': form, "section": "intranet", "page": 'group', "page_title": "Create new Group" }, context_instance=RequestContext(request))