diff --git a/binder/bcommon/forms.py b/binder/bcommon/forms.py new file mode 100644 index 0000000..5a23439 --- /dev/null +++ b/binder/bcommon/forms.py @@ -0,0 +1,10 @@ +from django import forms + +from bcommon.models import BindServer, Key + +class FormAddRecord(forms.Form): + dns_hostname = forms.CharField(max_length=100) + rr_domain = forms.CharField(max_length=100) + rr_name = forms.CharField(max_length=256) + rr_type = forms.ChoiceField(choices=(("A", "A"), ("MX", "MX"), ("CNAME", "CNAME"), ("AAAA", "AAAA"))) + rr_data = forms.CharField(max_length=256) diff --git a/binder/bcommon/views.py b/binder/bcommon/views.py index bed16d1..3b6e2ed 100644 --- a/binder/bcommon/views.py +++ b/binder/bcommon/views.py @@ -5,6 +5,7 @@ from django.template import Context from django.shortcuts import render_to_response, redirect from bcommon.helpers import list_server_zones +from bcommon.forms import FormAddRecord import dns.query import dns.zone @@ -31,6 +32,7 @@ def view_server_zones(request, dns_hostname): 'dns_hostname' : dns_hostname }) def list_zone(request, dns_hostname, zone_name): + # Need to move most of this logic into a helper method. try: zone = dns.zone.from_xfr(dns.query.xfr(dns_hostname, zone_name)) except dns.exception.FormError: @@ -59,3 +61,9 @@ def list_zone(request, dns_hostname, zone_name): 'dns_hostname' : dns_hostname, 'rr_server' : dns_hostname, 'rr_domain' : zone_name}) + +def add_record(request, dns_hostname, zone_name): + form = FormAddRecord(initial={ 'dns_hostname' : dns_hostname, + 'rr_domain' : zone_name }) + return render_to_response('bcommon/add_record.htm', + { 'form' : form }) diff --git a/binder/templates/bcommon/add_record.htm b/binder/templates/bcommon/add_record.htm new file mode 100644 index 0000000..bb0b9a5 --- /dev/null +++ b/binder/templates/bcommon/add_record.htm @@ -0,0 +1,10 @@ +{% extends "base.htm" %} + +{% block body %} +
+{% endblock body %} diff --git a/binder/templates/bcommon/list_zone.htm b/binder/templates/bcommon/list_zone.htm index 3250a26..7288a79 100644 --- a/binder/templates/bcommon/list_zone.htm +++ b/binder/templates/bcommon/list_zone.htm @@ -25,6 +25,7 @@