Browse Source

Merge pull request #31 from digitalocean/develop

Release 1.0.2
Jeremy Stretch 8 years ago
parent
commit
0b37d4f5e6
4 changed files with 15 additions and 5 deletions
  1. 2 2
      docs/getting-started.md
  2. 10 0
      netbox/dcim/models.py
  3. 1 1
      netbox/dcim/views.py
  4. 2 2
      netbox/utilities/forms.py

+ 2 - 2
docs/getting-started.md

@@ -259,10 +259,10 @@ Restart the nginx service to use the new configuration.
 
 ## gunicorn Configuration
 
-Save the following configuration file in the root netbox installation path (in this example, `/opt/netbox/`.) as `gunicorn_config.py`. Be sure to update the `pythonpath` variable if needed.
+Save the following configuration file in the root netbox installation path (in this example, `/opt/netbox/`.) as `gunicorn_config.py`. Be sure to verify the location of the gunicorn executable (e.g. `which gunicorn`) and to update the `pythonpath` variable if needed.
 
 ```
-command = '/usr/local/bin/gunicorn'
+command = '/usr/bin/gunicorn'
 pythonpath = '/opt/netbox/netbox'
 bind = '127.0.0.1:8001'
 workers = 3

+ 10 - 0
netbox/dcim/models.py

@@ -183,6 +183,16 @@ class Rack(CreatedUpdatedModel):
     def get_absolute_url(self):
         return reverse('dcim:rack', args=[self.pk])
 
+    def clean(self):
+
+        # Validate that Rack is tall enough to house the installed Devices
+        if self.pk:
+            top_device = Device.objects.filter(rack=self).order_by('-position').first()
+            min_height = top_device.position + top_device.device_type.u_height - 1
+            if self.u_height < min_height:
+                raise ValidationError("Rack must be at least {}U tall with currently installed devices."
+                                      .format(min_height))
+
     def to_csv(self):
         return ','.join([
             self.site.name,

+ 1 - 1
netbox/dcim/views.py

@@ -353,7 +353,7 @@ class ComponentTemplateCreateView(View):
 
             if not form.errors:
                 self.model.objects.bulk_create(component_templates)
-                messages.success(request, "Added {} compontent(s) to {}".format(len(component_templates), devicetype))
+                messages.success(request, "Added {} component(s) to {}".format(len(component_templates), devicetype))
                 if '_addanother' in request.POST:
                     return redirect(request.path)
                 else:

+ 2 - 2
netbox/utilities/forms.py

@@ -19,11 +19,11 @@ def expand_pattern(string):
     lead, pattern, remnant = re.split(EXPANSION_PATTERN, string, maxsplit=1)
     x, y = pattern.split('-')
     for i in range(int(x), int(y) + 1):
-        if remnant:
+        if re.search(EXPANSION_PATTERN, remnant):
             for string in expand_pattern(remnant):
                 yield "{}{}{}".format(lead, i, string)
         else:
-            yield "{}{}".format(lead, i)
+            yield "{}{}{}".format(lead, i, remnant)
 
 
 #