WIP: Initial form written to add record. Displays, but does not work yet.
This commit is contained in:
parent
27a121ca0a
commit
6a1275185d
|
@ -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)
|
|
@ -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 })
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{% extends "base.htm" %}
|
||||
|
||||
{% block body %}
|
||||
<form action="/foo" method="post">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
{% endblock body %}
|
|
@ -25,6 +25,7 @@
|
|||
<td>{{ current_record.rr_data }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<td colspan="6" align="right"><a href="/add_record/{{ rr_server }}/{{ rr_domain }}/">Add Record</a></td>
|
||||
</table>
|
||||
<input type="submit" value="Delete Selected"/>
|
||||
</form>
|
||||
|
|
|
@ -11,6 +11,7 @@ urlpatterns = patterns('',
|
|||
(r'^info/$', 'bcommon.views.list_servers'),
|
||||
(r'^info/(?P<dns_hostname>[a-zA-Z0-9.-]+)/$', 'bcommon.views.view_server_zones'),
|
||||
(r'^info/(?P<dns_hostname>[a-zA-Z0-9.-]+)/(?P<zone_name>[a-zA-Z0-9.-]+)/$', 'bcommon.views.list_zone'),
|
||||
(r'^add_record/(?P<dns_hostname>[a-zA-Z0-9.-]+)/(?P<zone_name>[a-zA-Z0-9.-]+)/$', 'bcommon.views.add_record'),
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
|
|
Loading…
Reference in New Issue