mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
Improve records table on zone page
This commit is contained in:
parent
fd98c0c2a8
commit
f225efa7c7
@ -49,4 +49,15 @@ class RecordBriefTable(BaseTable):
|
||||
class Meta(BaseTable.Meta):
|
||||
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')
|
||||
|
@ -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,
|
||||
})
|
||||
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user