mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-25 12:59:59 -06:00
Merge 'detail' tables into primaries for each model
This commit is contained in:
@@ -12,12 +12,13 @@ __all__ = (
|
||||
'ClusterTable',
|
||||
'ClusterGroupTable',
|
||||
'ClusterTypeTable',
|
||||
'VirtualMachineDetailTable',
|
||||
'VirtualMachineTable',
|
||||
'VirtualMachineVMInterfaceTable',
|
||||
'VMInterfaceTable',
|
||||
)
|
||||
|
||||
PRIMARY_IP_ORDERING = ('primary_ip4', 'primary_ip6') if settings.PREFER_IPV4 else ('primary_ip6', 'primary_ip4')
|
||||
|
||||
VMINTERFACE_BUTTONS = """
|
||||
{% if perms.ipam.add_ipaddress %}
|
||||
<a href="{% url 'ipam:ipaddress_add' %}?vminterface={{ record.pk }}&return_url={{ virtualmachine.get_absolute_url }}" class="btn btn-sm btn-success" title="Add IP Address">
|
||||
@@ -118,13 +119,7 @@ class VirtualMachineTable(BaseTable):
|
||||
)
|
||||
role = ColoredLabelColumn()
|
||||
tenant = TenantColumn()
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = VirtualMachine
|
||||
fields = ('pk', 'name', 'status', 'cluster', 'role', 'tenant', 'vcpus', 'memory', 'disk')
|
||||
|
||||
|
||||
class VirtualMachineDetailTable(VirtualMachineTable):
|
||||
comments = MarkdownColumn()
|
||||
primary_ip4 = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='IPv4 Address'
|
||||
@@ -133,19 +128,11 @@ class VirtualMachineDetailTable(VirtualMachineTable):
|
||||
linkify=True,
|
||||
verbose_name='IPv6 Address'
|
||||
)
|
||||
if settings.PREFER_IPV4:
|
||||
primary_ip = tables.Column(
|
||||
linkify=True,
|
||||
order_by=('primary_ip4', 'primary_ip6'),
|
||||
verbose_name='IP Address'
|
||||
)
|
||||
else:
|
||||
primary_ip = tables.Column(
|
||||
linkify=True,
|
||||
order_by=('primary_ip6', 'primary_ip4'),
|
||||
verbose_name='IP Address'
|
||||
)
|
||||
comments = MarkdownColumn()
|
||||
primary_ip = tables.Column(
|
||||
linkify=True,
|
||||
order_by=PRIMARY_IP_ORDERING,
|
||||
verbose_name='IP Address'
|
||||
)
|
||||
tags = TagColumn(
|
||||
url_name='virtualization:virtualmachine_list'
|
||||
)
|
||||
|
||||
@@ -171,7 +171,11 @@ class ClusterVirtualMachinesView(generic.ObjectView):
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
virtualmachines = VirtualMachine.objects.restrict(request.user, 'view').filter(cluster=instance)
|
||||
virtualmachines_table = tables.VirtualMachineTable(virtualmachines, orderable=False)
|
||||
virtualmachines_table = tables.VirtualMachineTable(
|
||||
virtualmachines,
|
||||
exclude=('cluster',),
|
||||
orderable=False
|
||||
)
|
||||
|
||||
return {
|
||||
'virtualmachines_table': virtualmachines_table,
|
||||
@@ -315,7 +319,7 @@ class VirtualMachineListView(generic.ObjectListView):
|
||||
queryset = VirtualMachine.objects.all()
|
||||
filterset = filtersets.VirtualMachineFilterSet
|
||||
filterset_form = forms.VirtualMachineFilterForm
|
||||
table = tables.VirtualMachineDetailTable
|
||||
table = tables.VirtualMachineTable
|
||||
template_name = 'virtualization/virtualmachine_list.html'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user