Sfoglia il codice sorgente

Fixes #12885: Permit mounting of devices in U100 (#12901)

* Fixes #12885: Permit mounting of devices in U100

* Define a RACK_U_HEIGHT_MAX constant
Jeremy Stretch 2 anni fa
parent
commit
6ef333ea68

+ 1 - 0
netbox/dcim/constants.py

@@ -11,6 +11,7 @@ DEVICETYPE_IMAGE_FORMATS = 'image/bmp,image/gif,image/jpeg,image/png,image/tiff,
 #
 #
 
 
 RACK_U_HEIGHT_DEFAULT = 42
 RACK_U_HEIGHT_DEFAULT = 42
+RACK_U_HEIGHT_MAX = 100
 
 
 RACK_ELEVATION_BORDER_WIDTH = 2
 RACK_ELEVATION_BORDER_WIDTH = 2
 RACK_ELEVATION_DEFAULT_LEGEND_WIDTH = 30
 RACK_ELEVATION_DEFAULT_LEGEND_WIDTH = 30

+ 1 - 1
netbox/dcim/migrations/0154_half_height_rack_units.py

@@ -18,6 +18,6 @@ class Migration(migrations.Migration):
         migrations.AlterField(
         migrations.AlterField(
             model_name='device',
             model_name='device',
             name='position',
             name='position',
-            field=models.DecimalField(blank=True, decimal_places=1, max_digits=4, null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(99.5)]),
+            field=models.DecimalField(blank=True, decimal_places=1, max_digits=4, null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(100.5)]),
         ),
         ),
     ]
     ]

+ 1 - 1
netbox/dcim/models/devices.py

@@ -568,7 +568,7 @@ class Device(PrimaryModel, ConfigContextModel):
         decimal_places=1,
         decimal_places=1,
         blank=True,
         blank=True,
         null=True,
         null=True,
-        validators=[MinValueValidator(1), MaxValueValidator(99.5)],
+        validators=[MinValueValidator(1), MaxValueValidator(RACK_U_HEIGHT_MAX + 0.5)],
         verbose_name='Position (U)',
         verbose_name='Position (U)',
         help_text=_('The lowest-numbered unit occupied by the device')
         help_text=_('The lowest-numbered unit occupied by the device')
     )
     )

+ 1 - 1
netbox/dcim/models/racks.py

@@ -126,7 +126,7 @@ class Rack(PrimaryModel, WeightMixin):
     u_height = models.PositiveSmallIntegerField(
     u_height = models.PositiveSmallIntegerField(
         default=RACK_U_HEIGHT_DEFAULT,
         default=RACK_U_HEIGHT_DEFAULT,
         verbose_name='Height (U)',
         verbose_name='Height (U)',
-        validators=[MinValueValidator(1), MaxValueValidator(100)],
+        validators=[MinValueValidator(1), MaxValueValidator(RACK_U_HEIGHT_MAX)],
         help_text=_('Height in rack units')
         help_text=_('Height in rack units')
     )
     )
     desc_units = models.BooleanField(
     desc_units = models.BooleanField(