Просмотр исходного кода

Fixes #9847: Respect desc_units when ordering rack units

jeremystretch 3 лет назад
Родитель
Сommit
a6be8dccf5
2 измененных файлов с 3 добавлено и 3 удалено
  1. 1 0
      docs/release-notes/version-3.3.md
  2. 2 3
      netbox/dcim/models/racks.py

+ 1 - 0
docs/release-notes/version-3.3.md

@@ -108,6 +108,7 @@ Custom field UI visibility has no impact on API operation.
 * [#9829](https://github.com/netbox-community/netbox/issues/9829) - Arrange custom fields by group when editing objects
 * [#9843](https://github.com/netbox-community/netbox/issues/9843) - Fix rendering of custom field values (regression from #9647)
 * [#9844](https://github.com/netbox-community/netbox/issues/9844) - Fix interface api request when creating/editing L2VPN termination
+* [#9847](https://github.com/netbox-community/netbox/issues/9847) - Respect `desc_units` when ordering rack units
 
 ### Plugins API
 

+ 2 - 3
netbox/dcim/models/racks.py

@@ -244,10 +244,9 @@ class Rack(NetBoxModel):
         """
         Return a list of unit numbers, top to bottom.
         """
-        max_position = self.u_height + decimal.Decimal(0.5)
         if self.desc_units:
-            drange(0.5, max_position, 0.5)
-        return drange(max_position, 0.5, -0.5)
+            return drange(decimal.Decimal(1.0), self.u_height + 1, 0.5)
+        return drange(self.u_height + decimal.Decimal(0.5), 0.5, -0.5)
 
     def get_status_color(self):
         return RackStatusChoices.colors.get(self.status)