mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 19:32:24 -06:00
Merge branch 'develop' into 4121-filter-lookup-expressions
This commit is contained in:
@@ -276,6 +276,7 @@ class PrefixForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
|
||||
vrf = DynamicModelChoiceField(
|
||||
queryset=VRF.objects.all(),
|
||||
required=False,
|
||||
label='VRF',
|
||||
widget=APISelect(
|
||||
api_url="/api/ipam/vrfs/",
|
||||
)
|
||||
|
||||
@@ -154,10 +154,24 @@ class NetHostContained(Lookup):
|
||||
return 'CAST(HOST(%s) AS INET) << %s' % (lhs, rhs), params
|
||||
|
||||
|
||||
#
|
||||
# Transforms
|
||||
#
|
||||
|
||||
class NetMaskLength(Transform):
|
||||
lookup_name = 'net_mask_length'
|
||||
function = 'MASKLEN'
|
||||
lookup_name = 'net_mask_length'
|
||||
|
||||
@property
|
||||
def output_field(self):
|
||||
return IntegerField()
|
||||
|
||||
|
||||
class Host(Transform):
|
||||
function = 'HOST'
|
||||
lookup_name = 'host'
|
||||
|
||||
|
||||
class Inet(Transform):
|
||||
function = 'INET'
|
||||
lookup_name = 'inet'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from django.db.models.expressions import RawSQL
|
||||
|
||||
from ipam.lookups import Host, Inet
|
||||
|
||||
|
||||
class IPAddressManager(models.Manager):
|
||||
@@ -13,4 +14,4 @@ class IPAddressManager(models.Manager):
|
||||
IP address as a /32 or /128.
|
||||
"""
|
||||
qs = super().get_queryset()
|
||||
return qs.annotate(host=RawSQL('INET(HOST(ipam_ipaddress.address))', [])).order_by('family', 'host')
|
||||
return qs.order_by('family', Inet(Host('address')))
|
||||
|
||||
@@ -26,7 +26,7 @@ RIR_UTILIZATION = """
|
||||
"""
|
||||
|
||||
RIR_ACTIONS = """
|
||||
<a href="{% url 'ipam:rir_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Changelog">
|
||||
<a href="{% url 'ipam:rir_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Change log">
|
||||
<i class="fa fa-history"></i>
|
||||
</a>
|
||||
{% if perms.ipam.change_rir %}
|
||||
@@ -48,7 +48,7 @@ ROLE_VLAN_COUNT = """
|
||||
"""
|
||||
|
||||
ROLE_ACTIONS = """
|
||||
<a href="{% url 'ipam:role_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Changelog">
|
||||
<a href="{% url 'ipam:role_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Change log">
|
||||
<i class="fa fa-history"></i>
|
||||
</a>
|
||||
{% if perms.ipam.change_role %}
|
||||
@@ -145,7 +145,7 @@ VLAN_ROLE_LINK = """
|
||||
"""
|
||||
|
||||
VLANGROUP_ACTIONS = """
|
||||
<a href="{% url 'ipam:vlangroup_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Changelog">
|
||||
<a href="{% url 'ipam:vlangroup_changelog' pk=record.pk %}" class="btn btn-default btn-xs" title="Change log">
|
||||
<i class="fa fa-history"></i>
|
||||
</a>
|
||||
{% with next_vid=record.get_next_available_vid %}
|
||||
@@ -385,7 +385,7 @@ class InterfaceIPAddressTable(BaseTable):
|
||||
"""
|
||||
List IP addresses assigned to a specific Interface.
|
||||
"""
|
||||
address = tables.TemplateColumn(IPADDRESS_ASSIGN_LINK, verbose_name='IP Address')
|
||||
address = tables.LinkColumn(verbose_name='IP Address')
|
||||
vrf = tables.TemplateColumn(VRF_LINK, verbose_name='VRF')
|
||||
status = tables.TemplateColumn(STATUS_LABEL)
|
||||
tenant = tables.TemplateColumn(template_code=TENANT_LINK)
|
||||
|
||||
Reference in New Issue
Block a user