diff --git a/docs/release-notes/version-2.7.md b/docs/release-notes/version-2.7.md index 4876476c9..bdc1d6f41 100644 --- a/docs/release-notes/version-2.7.md +++ b/docs/release-notes/version-2.7.md @@ -1,3 +1,13 @@ +# 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) **Note:** This release completely removes the topology map feature ([#2745](https://github.com/netbox-community/netbox/issues/2745)). @@ -172,7 +182,7 @@ REDIS = { 'SSL': False, } } -``` +``` 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 diff --git a/netbox/dcim/models/__init__.py b/netbox/dcim/models/__init__.py index b6716e324..ccbdafa83 100644 --- a/netbox/dcim/models/__init__.py +++ b/netbox/dcim/models/__init__.py @@ -390,7 +390,9 @@ class RackElevationHelperMixin: color = device.device_role.color link = drawing.add( 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))) @@ -405,10 +407,13 @@ class RackElevationHelperMixin: @staticmethod def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_): 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.text("add device", insert=text, class_='add-device')) diff --git a/netbox/ipam/fields.py b/netbox/ipam/fields.py index 845820432..72600d1b9 100644 --- a/netbox/ipam/fields.py +++ b/netbox/ipam/fields.py @@ -1,6 +1,6 @@ from django.core.exceptions import ValidationError from django.db import models -from netaddr import AddrFormatError, IPNetwork, IPAddress +from netaddr import AddrFormatError, IPNetwork from . import lookups from .formfields import IPFormField @@ -23,11 +23,9 @@ class BaseIPField(models.Field): if not value: return value 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)) except (TypeError, ValueError) as e: raise ValidationError(e) diff --git a/netbox/ipam/lookups.py b/netbox/ipam/lookups.py index 457cd7734..62b356c5d 100644 --- a/netbox/ipam/lookups.py +++ b/netbox/ipam/lookups.py @@ -103,6 +103,10 @@ class NetHost(Lookup): class NetIn(Lookup): 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): lhs, lhs_params = self.process_lhs(qn, connection) rhs, rhs_params = self.process_rhs(qn, connection) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 1460df66f..5cbd55bf4 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -760,7 +760,7 @@ class IPAddressAssignView(PermissionRequiredMixin, View): 'vrf', 'tenant', 'interface__device', 'interface__virtual_machine' ) # Limit to 100 results - addresses = filters.IPAddressFilter(request.POST, addresses).qs[:100] + addresses = filters.IPAddressFilterSet(request.POST, addresses).qs[:100] table = tables.IPAddressAssignTable(addresses) return render(request, 'ipam/ipaddress_assign.html', { diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index effff8d8d..cd0fac465 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -12,7 +12,7 @@ from django.core.exceptions import ImproperlyConfigured # Environment setup # -VERSION = '2.7.0' +VERSION = '2.7.1' # Hostname HOSTNAME = platform.node()