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:
18
netbox/dcim/migrations/0105_interface_name_collation.py
Normal file
18
netbox/dcim/migrations/0105_interface_name_collation.py
Normal 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'))},
|
||||
),
|
||||
]
|
@@ -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):
|
||||
|
@@ -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',
|
||||
|
Reference in New Issue
Block a user