def save(request): domain = get_object_or_404(models.Domain, pk=request.POST.get('id')) form = forms.DomainForm(request.POST,instance=domain) if form.is_valid(): currentdomain = form.save() currentdomain.xml = xmltool.build_domain_xml(request.POST) request.user.message_set.create(message=_("Domain successfully changed")) else: return render_to_response('virt/domainedit.html', {'form': form , 'domain': domain }, context_instance=RequestContext(request)) return HttpResponseRedirect(reverse('domain_edit',args=[domain.id]))
def add(request): if request.method == 'POST': form = forms.DomainForm(request.POST) if form.is_valid(): newdomain = form.save() newdomain.xml = xmltool.build_domain_xml(request.POST) newdomain.save() request.user.message_set.create(message=_("Domain registered successfully")) return HttpResponseRedirect(reverse('domain_get')) else: return render_to_response('virt/domainadd.html', { 'form' : form }, context_instance=RequestContext(request)) else: form = forms.DomainForm() return render_to_response('virt/domainadd.html', { 'form' : form }, context_instance=RequestContext(request))
def save(request): domain = get_object_or_404(models.Domain, pk=request.POST.get('id')) form = forms.DomainForm(request.POST, instance=domain) if form.is_valid(): currentdomain = form.save() currentdomain.xml = xmltool.build_domain_xml(request.POST) currentdomain.save() request.user.message_set.create( message=_("Domain successfully changed")) else: return render_to_response('virt/domainedit.html', { 'form': form, 'domain': domain }, context_instance=RequestContext(request)) return HttpResponseRedirect(reverse('domain_edit', args=[domain.id]))
def add(request): if request.method == 'POST': form = forms.DomainForm(request.POST) if form.is_valid(): newdomain = form.save() newdomain.xml = xmltool.build_domain_xml(request.POST) newdomain.save() request.user.message_set.create( message=_("Domain registered successfully")) return HttpResponseRedirect(reverse('domain_get')) else: return render_to_response('virt/domainadd.html', {'form': form}, context_instance=RequestContext(request)) else: form = forms.DomainForm() return render_to_response('virt/domainadd.html', {'form': form}, context_instance=RequestContext(request))