mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 17:59:11 -06:00
Merge pull request #248 from Zanthras/develop
possible fix for #243 generic sorting for device bays
This commit is contained in:
commit
d80ffd2308
@ -1,4 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
|
from operator import attrgetter
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import permission_required
|
from django.contrib.auth.decorators import permission_required
|
||||||
@ -12,6 +13,8 @@ from django.shortcuts import get_object_or_404, redirect, render
|
|||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
|
|
||||||
|
from natsort import natsorted
|
||||||
|
|
||||||
from ipam.models import Prefix, IPAddress, VLAN
|
from ipam.models import Prefix, IPAddress, VLAN
|
||||||
from circuits.models import Circuit
|
from circuits.models import Circuit
|
||||||
from extras.models import TopologyMap
|
from extras.models import TopologyMap
|
||||||
@ -521,7 +524,10 @@ def device(request, pk):
|
|||||||
.select_related('connected_as_a', 'connected_as_b', 'circuit')
|
.select_related('connected_as_a', 'connected_as_b', 'circuit')
|
||||||
mgmt_interfaces = Interface.objects.filter(device=device, mgmt_only=True)\
|
mgmt_interfaces = Interface.objects.filter(device=device, mgmt_only=True)\
|
||||||
.select_related('connected_as_a', 'connected_as_b', 'circuit')
|
.select_related('connected_as_a', 'connected_as_b', 'circuit')
|
||||||
device_bays = DeviceBay.objects.filter(device=device).select_related('installed_device__device_type__manufacturer')
|
device_bays = natsorted(
|
||||||
|
DeviceBay.objects.filter(device=device).select_related('installed_device__device_type__manufacturer'),
|
||||||
|
key=attrgetter("name")
|
||||||
|
)
|
||||||
|
|
||||||
# Gather any secrets which belong to this device
|
# Gather any secrets which belong to this device
|
||||||
secrets = device.secrets.all()
|
secrets = device.secrets.all()
|
||||||
|
@ -15,3 +15,4 @@ py-gfm==0.1.3
|
|||||||
pycrypto==2.6.1
|
pycrypto==2.6.1
|
||||||
sqlparse==0.1.19
|
sqlparse==0.1.19
|
||||||
xmltodict==0.10.2
|
xmltodict==0.10.2
|
||||||
|
natsort>=5.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user