Zone/record list view

master
Dustin 2015-02-15 18:56:36 -06:00
parent ad70b77db5
commit 913989f31c
2 changed files with 89 additions and 4 deletions

View File

@ -119,11 +119,14 @@ class ZoneController(BaseController):
def GET(self, request, name): def GET(self, request, name):
response = request.ResponseClass() response = request.ResponseClass()
response.content_type = 'application/json'
zone = self.get_zone(name) zone = self.get_zone(name)
if request.want == 'json':
response.content_type = 'application/json'
zone_d = zone.as_dict() zone_d = zone.as_dict()
zone_d['records'] = list(map(model.Record.as_dict, zone.records)) zone_d['records'] = list(map(model.Record.as_dict, zone.records))
json.dump(zone_d, response.body_file) json.dump(zone_d, response.body_file)
else:
response.text = self.render('zone.html.j2', zone=zone)
return response return response
HEAD = GET HEAD = GET

View File

@ -0,0 +1,82 @@
{#- vim: set sw=2 ts=2 sts=2 et : -#}
{% set page_title = zone.name %}
{% extends 'base.html.j2' %}
{%- block breadcrumbs %}
<li><a href="{{ url('/zones/') }}">Zones</a></li>
<li class="current"><a href="{{ url('/zones/') }}{{ zone.name }}">{{ zone.name }}</a></li>
{%- endblock %}
{% block body %}
<div class="row">
<div class="medium-6 columns">
<table class="key-value" style="width: 100%;">
<tbody>
<tr>
<th scope="row">Contact:</th>
<td>{{ zone.contact }}</td>
</tr>
<tr>
<th scope="row">Source:</th>
<td>{{ zone.source }}</td>
</tr>
<tr>
<th scope="row">Serial:</th>
<td>{{ zone.serial }}</td>
</tr>
</tbody>
</table>
</div>
<div class="medium-6 columns">
<table class="key-value" style="width: 100%;">
<tbody>
<tr>
<th scope="row"><abbr title="Time To Live">TTL</abbr>:</th>
<td>{{ zone.ttl }}</td>
</tr>
<tr>
<th scope="row">Refresh Interval:</th>
<td>{{ zone.refresh }}</td>
</tr>
<tr>
<th scope="row">Retry Interval:</th>
<td>{{ zone.retry }}</td>
</tr>
<tr>
<th scope="row">Expiry Time:</th>
<td>{{ zone.expire }}</td>
</tr>
<tr>
<th scope="row">Minimum (default)
<abbr title="Time To Live">TTL</abbr>:</th>
<td>{{ zone.minimum }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="column">
<h3>Records</h3>
<a class="tiny button" href="?new">New Record</a>
<table class="pretty" style="width: 100%;">
<thead>
<tr>
<th scope="col">Host</th>
<th scope="col"><abbr title="Time To Live">TTL</abbr></th>
<th scope="col">Type</th>
<th scope="col">Data</th>
</tr>
</thead>
<tbody>
{% for record in zone.records -%}
<tr>
<td><a href="{{ url('/records/') }}{{ record.id }}">{{ record.host }}</a></td>
<td>{{ record.ttl }}</td>
<td>{{ record.rdtype }}</td>
<td>{% if record.mx_prio %}{{ record.mx_prio }} {% endif %}{{ record.data }}</td>
</tr>
{% endfor -%}
</tbody>
</table>
</div>
</div>
{% endblock %}