Permalink
Browse files

Starting to integrate with client.

  • Loading branch information...
1 parent dd3d9d9 commit 83b69fec4c6ebe272a66965ae1fddec780ce64aa @jonatasoliveira committed with root Jul 31, 2011
Showing with 23 additions and 9 deletions.
  1. +2 −4 pymandns/control/forms.py
  2. +18 −5 pymandns/control/views.py
  3. +3 −0 pymandns/settings.py
View
6 pymandns/control/forms.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
from django import forms
class DomainForm(forms.Form):
@@ -10,7 +12,3 @@ class DomainForm(forms.Form):
soa_expire = forms.IntegerField(label=u'Expire time')
soa_minimum = forms.IntegerField(label=u'Minimum time')
- #def save(self):
- # domain = Domain()
- # return domain
-
View
23 pymandns/control/views.py
@@ -1,27 +1,40 @@
-# Create your views here.
+# -*- coding: utf-8 -*-
+
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.contrib import messages
+from pyManDNS_Cli import *
from forms import *
from models import *
+import settings
+
def dashboard(request):
return render_to_response('dashboard.html', locals(),
context_instance=RequestContext(request))
-def domain_create(request):
+def domain_create(request):
if request.method == 'POST':
domain_form = DomainForm(request.POST)
if domain_form.is_valid():
#import pdb; pdb.set_trace()
- messages.success(request, u'The domains %s was created.' % domain_form.cleaned_data['domain'])
- return redirect('dashboard')
- pass
+
+ try:
+ domain_client = pyManDNS_Cli_Domain(
+ settings.MANAGER_HOST, settings.MANAGER_PORT)
+ result = domain_client.create(**domain_form.cleaned_data)
+
+ messages.success(request,
+ 'The domain %s was created.' % domain_form.cleaned_data['domain'])
+ return redirect('dashboard')
+ except Exception, e:
+ messages.error(request, u'>>> ERROR: %s' % e)
else:
domain_form = DomainForm()
return render_to_response('domain_create.html', locals(),
context_instance=RequestContext(request))
+
View
3 pymandns/settings.py
@@ -9,6 +9,9 @@
MANAGERS = ADMINS
+MANAGER_HOST = '192.168.1.204'
+MANAGER_PORT = '3333'
+
#DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

0 comments on commit 83b69fe

Please sign in to comment.