1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #4336: Ensure interfaces without a subinterface ID are ordered before subinterface zero

This commit is contained in:
Jeremy Stretch
2020-04-21 16:13:34 -04:00
parent ada55dfdfb
commit 131d2c97ca
7 changed files with 56 additions and 18 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2020-04-21 20:13
from django.db import migrations
import utilities.query_functions
class Migration(migrations.Migration):
dependencies = [
('dcim', '0104_correct_infiniband_types'),
]
operations = [
migrations.AlterModelOptions(
name='interface',
options={'ordering': ('device', utilities.query_functions.CollateAsChar('_name'))},
),
]

View File

@@ -16,6 +16,7 @@ from extras.models import ObjectChange, TaggedItem
from extras.utils import extras_features
from utilities.fields import NaturalOrderingField
from utilities.ordering import naturalize_interface
from utilities.query_functions import CollateAsChar
from utilities.utils import serialize_object
from virtualization.choices import VMInterfaceTypeChoices
@@ -676,7 +677,7 @@ class Interface(CableTermination, ComponentModel):
class Meta:
# TODO: ordering and unique_together should include virtual_machine
ordering = ('device', '_name')
ordering = ('device', CollateAsChar('_name'))
unique_together = ('device', 'name')
def __str__(self):

View File

@@ -23,28 +23,34 @@ class NaturalOrderingTestCase(TestCase):
INTERFACES = [
'0',
'0.0',
'0.1',
'0.2',
'0.10',
'0.100',
'0:1',
'0:1.0',
'0:1.1',
'0:1.2',
'0:1.10',
'0:2',
'0:2.0',
'0:2.1',
'0:2.2',
'0:2.10',
'1',
'1.0',
'1.1',
'1.2',
'1.10',
'1.100',
'1:1',
'1:1.0',
'1:1.1',
'1:1.2',
'1:1.10',
'1:2',
'1:2.0',
'1:2.1',
'1:2.2',
'1:2.10',