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

Merge branch 'develop' into 2921-tags-select2

hSaria 6 лет назад
Родитель
Сommit
8b02cd47fb

+ 12 - 2
docs/release-notes/version-2.7.md

@@ -1,4 +1,4 @@
-# v2.7.1 (FUTURE)
+# v2.7.2 (FUTURE)
 
 
 ## Enhancements
 ## Enhancements
 
 
@@ -6,6 +6,16 @@
 
 
 ---
 ---
 
 
+# v2.7.1 (2020-01-16)
+
+## Bug Fixes
+
+* [#3941](https://github.com/netbox-community/netbox/issues/3941) - Fixed exception when attempting to assign IP to interface
+* [#3943](https://github.com/netbox-community/netbox/issues/3943) - Prevent rack elevation links from opening new tabs/windows
+* [#3944](https://github.com/netbox-community/netbox/issues/3944) - Fix AttributeError exception when viewing prefixes list
+
+---
+
 # v2.7.0 (2020-01-16)
 # v2.7.0 (2020-01-16)
 
 
 **Note:** This release completely removes the topology map feature ([#2745](https://github.com/netbox-community/netbox/issues/2745)).
 **Note:** This release completely removes the topology map feature ([#2745](https://github.com/netbox-community/netbox/issues/2745)).
@@ -180,7 +190,7 @@ REDIS = {
         'SSL': False,
         'SSL': False,
     }
     }
 }
 }
-``` 
+```
 
 
 Note that the `CACHE_DATABASE` parameter has been removed and the connection settings have been duplicated for both
 Note that the `CACHE_DATABASE` parameter has been removed and the connection settings have been duplicated for both
 `webhooks` and `caching`. This allows the user to make use of separate Redis instances if desired. It is fine to use the
 `webhooks` and `caching`. This allows the user to make use of separate Redis instances if desired. It is fine to use the

+ 10 - 5
netbox/dcim/models/__init__.py

@@ -390,7 +390,9 @@ class RackElevationHelperMixin:
         color = device.device_role.color
         color = device.device_role.color
         link = drawing.add(
         link = drawing.add(
             drawing.a(
             drawing.a(
-                reverse('dcim:device', kwargs={'pk': device.pk}), fill='black'
+                href=reverse('dcim:device', kwargs={'pk': device.pk}),
+                target='_top',
+                fill='black'
             )
             )
         )
         )
         link.add(drawing.rect(start, end, fill='#{}'.format(color)))
         link.add(drawing.rect(start, end, fill='#{}'.format(color)))
@@ -405,10 +407,13 @@ class RackElevationHelperMixin:
     @staticmethod
     @staticmethod
     def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_):
     def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_):
         link = drawing.add(
         link = drawing.add(
-            drawing.a('{}?{}'.format(
-                reverse('dcim:device_add'),
-                urlencode({'rack': rack.pk, 'site': rack.site.pk, 'face': face_id, 'position': id_})
-            ))
+            drawing.a(
+                href='{}?{}'.format(
+                    reverse('dcim:device_add'),
+                    urlencode({'rack': rack.pk, 'site': rack.site.pk, 'face': face_id, 'position': id_})
+                ),
+                target='_top'
+            )
         )
         )
         link.add(drawing.rect(start, end, class_=class_))
         link.add(drawing.rect(start, end, class_=class_))
         link.add(drawing.text("add device", insert=text, class_='add-device'))
         link.add(drawing.text("add device", insert=text, class_='add-device'))

+ 4 - 6
netbox/ipam/fields.py

@@ -1,6 +1,6 @@
 from django.core.exceptions import ValidationError
 from django.core.exceptions import ValidationError
 from django.db import models
 from django.db import models
-from netaddr import AddrFormatError, IPNetwork, IPAddress
+from netaddr import AddrFormatError, IPNetwork
 
 
 from . import lookups
 from . import lookups
 from .formfields import IPFormField
 from .formfields import IPFormField
@@ -23,11 +23,9 @@ class BaseIPField(models.Field):
         if not value:
         if not value:
             return value
             return value
         try:
         try:
-            if '/' in str(value):
-                return IPNetwork(value)
-            else:
-                return IPAddress(value)
-        except AddrFormatError as e:
+            # Always return a netaddr.IPNetwork object. (netaddr.IPAddress does not provide a mask.)
+            return IPNetwork(value)
+        except AddrFormatError:
             raise ValidationError("Invalid IP address format: {}".format(value))
             raise ValidationError("Invalid IP address format: {}".format(value))
         except (TypeError, ValueError) as e:
         except (TypeError, ValueError) as e:
             raise ValidationError(e)
             raise ValidationError(e)

+ 4 - 0
netbox/ipam/lookups.py

@@ -103,6 +103,10 @@ class NetHost(Lookup):
 class NetIn(Lookup):
 class NetIn(Lookup):
     lookup_name = 'net_in'
     lookup_name = 'net_in'
 
 
+    def get_prep_lookup(self):
+        # Don't cast the query value to a netaddr object, since it may or may not include a mask.
+        return self.rhs
+
     def as_sql(self, qn, connection):
     def as_sql(self, qn, connection):
         lhs, lhs_params = self.process_lhs(qn, connection)
         lhs, lhs_params = self.process_lhs(qn, connection)
         rhs, rhs_params = self.process_rhs(qn, connection)
         rhs, rhs_params = self.process_rhs(qn, connection)

+ 1 - 1
netbox/ipam/views.py

@@ -760,7 +760,7 @@ class IPAddressAssignView(PermissionRequiredMixin, View):
                 'vrf', 'tenant', 'interface__device', 'interface__virtual_machine'
                 'vrf', 'tenant', 'interface__device', 'interface__virtual_machine'
             )
             )
             # Limit to 100 results
             # Limit to 100 results
-            addresses = filters.IPAddressFilter(request.POST, addresses).qs[:100]
+            addresses = filters.IPAddressFilterSet(request.POST, addresses).qs[:100]
             table = tables.IPAddressAssignTable(addresses)
             table = tables.IPAddressAssignTable(addresses)
 
 
         return render(request, 'ipam/ipaddress_assign.html', {
         return render(request, 'ipam/ipaddress_assign.html', {

+ 1 - 1
netbox/netbox/settings.py

@@ -12,7 +12,7 @@ from django.core.exceptions import ImproperlyConfigured
 # Environment setup
 # Environment setup
 #
 #
 
 
-VERSION = '2.7.0'
+VERSION = '2.7.2-dev'
 
 
 # Hostname
 # Hostname
 HOSTNAME = platform.node()
 HOSTNAME = platform.node()