clean up listing server zones, remove error_context code

This commit is contained in:
Jeffrey Forman 2012-10-28 08:45:08 -04:00
parent a3e0dcc8cc
commit 87d0b08b50
3 changed files with 9 additions and 16 deletions

View File

@ -24,7 +24,7 @@ class BindServer(models.Model):
try: try:
http_request = urllib2.urlopen(myreq) http_request = urllib2.urlopen(myreq)
except urllib2.URLError, err_reason: # Error retrieving zone list. except urllib2.URLError, err_reason: # Error retrieving zone list.
return { 'errors' : err_reason, 'error_context' : "Trying to retrieve zone list from %s" % self.hostname } return { 'errors' : "Trying to retrieve zone list from %s: %s" % (self.hostname, err_reason) }
return_array = [] return_array = []
xmloutput = http_request.read() xmloutput = http_request.read()

View File

@ -25,23 +25,21 @@ def view_server_list(request):
def view_server_zones(request, dns_server): def view_server_zones(request, dns_server):
""" Display the list of DNS zones a particular DNS host provides. """ """ Display the list of DNS zones a particular DNS host provides. """
errors = ""
zone_array = {}
try: try:
this_server = BindServer.objects.get(hostname=dns_server) this_server = BindServer.objects.get(hostname=dns_server)
zone_array = this_server.list_zones() zone_array = this_server.list_zones()
except BindServer.DoesNotExist, err: except BindServer.DoesNotExist, err:
return render_to_response('bcommon/list_server_zones.htm', errors = err
{ 'errors' : "The server %s does not exist in this Binder instance." % dns_server },
context_instance=RequestContext(request))
if 'errors' in zone_array: if "errors" in zone_array:
return render_to_response('bcommon/list_server_zones.htm', errors = zone_array["errors"]
{ 'errors' : zone_array['errors'],
'error_context' : zone_array['error_context'] })
return render_to_response('bcommon/list_server_zones.htm', return render_to_response('bcommon/list_server_zones.htm',
{ 'zone_array' : zone_array, { "errors" : errors,
'dns_server' : dns_server }, "dns_server" : dns_server,
context_instance=RequestContext(request)) "zone_array" : zone_array})
def view_zone_records(request, dns_server, zone_name): def view_zone_records(request, dns_server, zone_name):
""" Display the list of records for a a particular zone.""" """ Display the list of records for a a particular zone."""

View File

@ -34,18 +34,13 @@
</div> </div>
{% block errors %} {% block errors %}
{% if errors %} {% if errors %}
<div class="alert alert-error"> <div class="alert alert-error">
Errors were encountered: Errors were encountered:
<br> <br>
{{ errors }} {{ errors }}
{% if error_context %}
{{ error_context }}
{% endif %}
</div> </div>
{% endif %} {% endif %}
{% endblock errors %} {% endblock errors %}
{% block body %} {% block body %}