Improve records table on zone page

This commit is contained in:
rdujardin 2016-07-27 12:08:22 +02:00
parent fd98c0c2a8
commit f225efa7c7
3 changed files with 20 additions and 39 deletions

View File

@ -50,3 +50,14 @@ class RecordBriefTable(BaseTable):
model=Record
fields = ('name', 'record_type', 'priority', 'zone')
class RecordZoneTable(BaseTable):
name = tables.LinkColumn('dns:record', args=[Accessor('pk')], verbose_name='Name')
record_type = tables.Column(verbose_name='Type')
priority = tables.Column(verbose_name='Priority')
address = tables.LinkColumn('ipam:ipaddress', args=[Accessor('address.pk')], verbose_name='IP Address')
value = tables.Column(verbose_name='Value')
class Meta(BaseTable.Meta):
model=Record
fields = ('name', 'record_type', 'priority', 'address', 'value')

View File

@ -13,6 +13,7 @@ from utilities.views import (
from . import filters, forms, tables
from .models import Zone, Record
from .tables import RecordZoneTable
#
# Zones
@ -33,6 +34,10 @@ def zone(request, pk):
record_count = len(records)
bind_export = zone.to_bind(records)
# DNS records
dns_records = Record.objects.filter(zone=zone)
dns_records_table = RecordZoneTable(dns_records)
if request.GET.get('bind_export'):
response = HttpResponse(
bind_export,
@ -47,6 +52,7 @@ def zone(request, pk):
'zone': zone,
'records': records,
'record_count': record_count,
'dns_records_table': dns_records_table,
'bind_export': bind_export,
})

View File

@ -112,45 +112,9 @@
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Records</strong>
</div>
{% if records %}
<table class="table table-hover panel-body">
{% for r in records %}
<tr>
<td>
<a href="{% url 'dns:record' pk=r.pk %}">{{ r }}</a>
</td>
<td>{{ r.record_type }}</td>
<td>
{% if r.priority %}
{{ r.priority }}
{% else %}
-
{% endif %}
</td>
<td>
{% if r.address %}
<a href="{% url 'ipam:ipaddress' pk=r.address.pk %}">{{ r.address }}</a>
{% else %}
-
{% endif %}
</td>
<td>
{% if r.value %}
{{ r.value }}
{% else %}
-
{% endif %}
</tr>
{% endfor %}
</table>
{% else %}
<div class="panel-body text-muted">None</div>
{% endif %}
</div>
{% with heading='Records' %}
{% render_table dns_records_table 'panel_table.html' %}
{% endwith %}
</div>
</div>
<div class="row">