diff --git a/binder/templates/base.htm b/binder/templates/base.htm index 88481b9..5b928d4 100644 --- a/binder/templates/base.htm +++ b/binder/templates/base.htm @@ -28,8 +28,7 @@ diff --git a/binder/templates/bcommon/add_cname_record_form.htm b/binder/templates/bcommon/add_cname_record_form.htm index db75ed0..0d1634a 100644 --- a/binder/templates/bcommon/add_cname_record_form.htm +++ b/binder/templates/bcommon/add_cname_record_form.htm @@ -1,8 +1,6 @@ {% extends "base.htm" %} -{% block pageheader %} -Add CNAME record for {{ originating_record }} -{% endblock pageheader %} +{% block pageheader %}Add CNAME record for {{ originating_record }}{% endblock pageheader %} {% block body %}
{% csrf_token %} @@ -10,8 +8,8 @@ Add CNAME record for {{ originating_record }}
- {{dns_server}} - + {{dns_server.hostname}} +
@@ -27,8 +25,8 @@ Add CNAME record for {{ originating_record }}
- .{{zone_name}} - + .{{zone_name}} +
{% if form_errors.cname %}
@@ -43,7 +41,7 @@ Add CNAME record for {{ originating_record }}
- - {% for key in tsig_keys %} - - {% endfor %} + {% for key in tsig_keys %} + + {% empty %} + + {% endfor %}
- {% endblock body %} diff --git a/binder/templates/bcommon/add_record_form.htm b/binder/templates/bcommon/add_record_form.htm index fbe7d6b..b684755 100644 --- a/binder/templates/bcommon/add_record_form.htm +++ b/binder/templates/bcommon/add_record_form.htm @@ -1,28 +1,25 @@ {% extends "base.htm" %} -{% block pageheader %} -Add record in {{ zone_name }} -{% endblock pageheader %} +{% block pageheader %}Add record in {{ zone_name }}{% endblock pageheader %} {% block body %}
{% csrf_token %} Create Record - +
- {{dns_server}} - + {{dns_server.hostname}} +
-
- .{{zone_name}} + .{{zone_name}}
{% if form_errors.record_name %}
@@ -51,7 +48,7 @@ Add record in {{ zone_name }}
- +
{% if form_errors.record_data %}
@@ -66,7 +63,7 @@ Add record in {{ zone_name }}
- + + {% empty %} +
@@ -98,5 +96,4 @@ Add record in {{ zone_name }} - {% endblock body %} diff --git a/binder/templates/bcommon/delete_record_initial.htm b/binder/templates/bcommon/delete_record_initial.htm index 8fc1d78..d27c65a 100644 --- a/binder/templates/bcommon/delete_record_initial.htm +++ b/binder/templates/bcommon/delete_record_initial.htm @@ -1,15 +1,12 @@ {% extends "base.htm" %} -{% block pageheader %} -Delete record(s) in {{ zone_name }} -{% endblock pageheader %} +{% block pageheader %}Delete record(s) in {{ zone_name }}{% endblock pageheader %} {% block body %} - {% csrf_token %} - + @@ -17,7 +14,7 @@ Delete record(s) in {{ zone_name }} - + @@ -31,9 +28,10 @@ Delete record(s) in {{ zone_name }} @@ -45,5 +43,4 @@ Delete record(s) in {{ zone_name }}
Server{{ dns_server }}{{ dns_server.hostname }}
ZoneKey
- {% endblock body %} diff --git a/binder/templates/bcommon/list_server_zones.htm b/binder/templates/bcommon/list_server_zones.htm index fbece20..4522f1f 100644 --- a/binder/templates/bcommon/list_server_zones.htm +++ b/binder/templates/bcommon/list_server_zones.htm @@ -1,9 +1,6 @@ {% extends "base.htm" %} -{% block pageheader %} -Server Zone List for {{ dns_server }} -{% endblock pageheader %} - +{% block pageheader %}Server Zone List for {{ dns_server.hostname }}{% endblock pageheader %} {% block body %} @@ -16,7 +13,7 @@ Server Zone List for {{ dns_server }} {% for current_view, cv_data in cz_data.iteritems %} @@ -24,5 +21,4 @@ Server Zone List for {{ dns_server }} {% endfor %} {% endfor %}
- {{ current_zone }} + {{ current_zone }} {{ current_view }} {{ cv_data.serial }}
- {% endblock body %} diff --git a/binder/templates/bcommon/list_servers.htm b/binder/templates/bcommon/list_servers.htm index 9343911..70181c9 100644 --- a/binder/templates/bcommon/list_servers.htm +++ b/binder/templates/bcommon/list_servers.htm @@ -1,9 +1,6 @@ {% extends "base.htm" %} - -{% block pageheader %} -Server List -{% endblock pageheader %} +{% block pageheader %}Server List{% endblock pageheader %} {% block body %} @@ -21,5 +18,4 @@ Server List {% endfor %}
- {% endblock body %} diff --git a/binder/templates/bcommon/list_zone.htm b/binder/templates/bcommon/list_zone.htm index 1aa334f..f082cd3 100644 --- a/binder/templates/bcommon/list_zone.htm +++ b/binder/templates/bcommon/list_zone.htm @@ -1,11 +1,8 @@ {% extends "base.htm" %} -{% block pageheader %} -Zone listing for {{ zone_name }} on {{ dns_server }} -{% endblock pageheader %} +{% block pageheader %}Zone listing for {{ zone_name }} on {{ dns_server.hostname }}{% endblock pageheader %} {% block body %} - {% if not errors %}
{% csrf_token %} @@ -19,7 +16,7 @@ Zone listing for {{ zone_name }} on {{ dns_server }} - + {% for current_record in zone_array %} @@ -32,13 +29,13 @@ Zone listing for {{ zone_name }} on {{ dns_server }} @@ -47,8 +44,8 @@ Zone listing for {{ zone_name }} on {{ dns_server }}
- - + +
-Add Record - +Add Record +
{% endif %} {% endblock body %} diff --git a/binder/templates/bcommon/response_result.htm b/binder/templates/bcommon/response_result.htm index 78af437..e499ffb 100644 --- a/binder/templates/bcommon/response_result.htm +++ b/binder/templates/bcommon/response_result.htm @@ -1,9 +1,6 @@ {% extends "base.htm" %} - -{% block pageheader %} -Record Result -{% endblock pageheader %} +{% block pageheader %}Record Result{% endblock pageheader %} {% block body %} diff --git a/binder/templates/index.htm b/binder/templates/index.htm index 4c7752d..a67a5c6 100644 --- a/binder/templates/index.htm +++ b/binder/templates/index.htm @@ -1,8 +1,6 @@ {% extends "base.htm" %} -{% block pageheader %} -Home -{% endblock pageheader %} +{% block pageheader %}Home{% endblock pageheader %} {% block body %} diff --git a/binder/views.py b/binder/views.py index d6b9ed2..16c4281 100644 --- a/binder/views.py +++ b/binder/views.py @@ -11,6 +11,7 @@ def home_index(request): """ List the main index page for Binder. """ return render(request, "index.htm") + def view_server_list(request): """ List the DNS servers configured in the database. """ server_list = models.BindServer.objects.all().order_by("hostname") @@ -21,54 +22,62 @@ def view_server_list(request): return render(request, "bcommon/list_servers.htm", { "server_info" : server_info}) + def view_server_zones(request, dns_server): """ Display the list of DNS zones a particular DNS host provides. """ errors = "" zone_array = {} try: this_server = models.BindServer.objects.get(hostname=dns_server) - zone_array = this_server.list_zones() except models.BindServer.DoesNotExist, err: errors = "There is no configured server by that name: %s" % dns_server - except exceptions.ZoneException, err: - errors = "Unable to list server zones. Error: %s" % err + else: + try: + zone_array = this_server.list_zones() + except exceptions.ZoneException, err: + errors = "Unable to list server zones. Error: %s" % err return render(request, "bcommon/list_server_zones.htm", { "errors" : errors, - "dns_server" : dns_server, + "dns_server" : this_server, "zone_array" : zone_array}) + def view_zone_records(request, dns_server, zone_name): """ Display the list of records for a particular zone. """ errors = "" zone_array = {} + this_server = models.BindServer.objects.get(hostname=dns_server) try: - this_server = models.BindServer.objects.get(hostname=dns_server) zone_array = this_server.list_zone_records(zone_name) except exceptions.TransferException, err: return render(request, "bcommon/list_zone.htm", { "errors" : err, "zone_name" : zone_name, - "dns_server" : dns_server}) + "dns_server" : this_server}) except models.BindServer.DoesNotExist: errors = "Requesting a zone listing for a Bind server that is not configured: %s" % dns_server return render(request, "bcommon/list_zone.htm", { "zone_array" : zone_array, - "dns_server" : dns_server, + "dns_server" : this_server, "zone_name" : zone_name, "errors" : errors}) + def view_add_record(request, dns_server, zone_name): """ View to provide form to add a DNS record. """ + this_server = models.BindServer.objects.get(hostname=dns_server) + return render(request, "bcommon/add_record_form.htm", - { "dns_server" : dns_server, + { "dns_server" : this_server, "zone_name" : zone_name, "tsig_keys" : models.Key.objects.all(), "ttl_choices" : local_settings.TTL_CHOICES, "record_type_choices" : local_settings.RECORD_TYPE_CHOICES, }) + def view_add_record_result(request): """ Process the input given to add a DNS record. """ errors = "" @@ -104,21 +113,28 @@ def view_add_record_result(request): { "errors" : errors, "response" : response }) + dns_server = models.BindServer.objects.get(hostname=request.POST["dns_server"]) + return render(request, "bcommon/add_record_form.htm", - { "dns_server" : request.POST["dns_server"], + { "dns_server" : dns_server, "zone_name" : request.POST["zone_name"], "form_errors" : form.errors, "form_data" : request.POST }) + def view_add_cname_record(request, dns_server, zone_name, record_name): """ Process given input to add a CNAME pointer.""" + + this_server = models.BindServer.objects.get(hostname=dns_server) + return render(request, "bcommon/add_cname_record_form.htm", - { "dns_server" : dns_server, + { "dns_server" : this_server, "originating_record" : "%s.%s" % (record_name, zone_name), "zone_name" : zone_name, "ttl_choices" : local_settings.TTL_CHOICES, "tsig_keys" : models.Key.objects.all() }) + def view_add_cname_result(request): """ Process input on the CNAME form and provide a response.""" if request.method == "GET": @@ -144,8 +160,10 @@ def view_add_cname_result(request): {"response" : add_cname_response, "errors" : errors }) + dns_server = models.BindServer.objects.get(hostname=request.POST["dns_server"]) + return render(request, "bcommon/add_cname_record_form.htm", - { "dns_server" : request.POST["dns_server"], + { "dns_server" : dns_server, "zone_name" : request.POST["zone_name"], "record_name" : request.POST["cname"], "originating_record" : request.POST["originating_record"], @@ -160,7 +178,7 @@ def view_delete_record(request): if request.method == "GET": return redirect("/") - dns_server = request.POST["dns_server"] + dns_server = models.BindServer.objects.get(hostname=request.POST["dns_server"]) zone_name = request.POST["zone_name"] rr_list = request.POST.getlist("rr_list")