mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
* [#7246](https://github.com/netbox-community/netbox/issues/7246) - Don't attempt to URL-decode NAPALM response payloads
|
||||||
* [#7962](https://github.com/netbox-community/netbox/issues/7962) - Fix user menu under report/script result view
|
* [#7962](https://github.com/netbox-community/netbox/issues/7962) - Fix user menu under report/script result view
|
||||||
|
* [#8097](https://github.com/netbox-community/netbox/issues/8097) - Fix styling of Markdown tables
|
||||||
* [#8131](https://github.com/netbox-community/netbox/issues/8131) - Restore annotation of available IPs under prefix IPs view
|
* [#8131](https://github.com/netbox-community/netbox/issues/8131) - Restore annotation of available IPs under prefix IPs view
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -15,14 +15,14 @@ from circuits.models import Circuit
|
|||||||
from dcim import filtersets
|
from dcim import filtersets
|
||||||
from dcim.models import *
|
from dcim.models import *
|
||||||
from extras.api.views import ConfigContextQuerySetMixin, CustomFieldModelViewSet
|
from extras.api.views import ConfigContextQuerySetMixin, CustomFieldModelViewSet
|
||||||
from ipam.models import Prefix, VLAN, ASN
|
from ipam.models import Prefix, VLAN
|
||||||
from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired
|
from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired
|
||||||
from netbox.api.exceptions import ServiceUnavailable
|
from netbox.api.exceptions import ServiceUnavailable
|
||||||
from netbox.api.metadata import ContentTypeMetadata
|
from netbox.api.metadata import ContentTypeMetadata
|
||||||
from netbox.api.views import ModelViewSet
|
from netbox.api.views import ModelViewSet
|
||||||
from netbox.config import get_config
|
from netbox.config import get_config
|
||||||
from utilities.api import get_serializer_for_model
|
from utilities.api import get_serializer_for_model
|
||||||
from utilities.utils import count_related, decode_dict
|
from utilities.utils import count_related
|
||||||
from virtualization.models import VirtualMachine
|
from virtualization.models import VirtualMachine
|
||||||
from . import serializers
|
from . import serializers
|
||||||
from .exceptions import MissingFilterException
|
from .exceptions import MissingFilterException
|
||||||
|
@ -288,45 +288,6 @@ def flatten_dict(d, prefix='', separator='.'):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def decode_dict(encoded_dict: Dict, *, decode_keys: bool = True) -> Dict:
|
|
||||||
"""
|
|
||||||
Recursively URL decode string keys and values of a dict.
|
|
||||||
|
|
||||||
For example, `{'1%2F1%2F1': {'1%2F1%2F2': ['1%2F1%2F3', '1%2F1%2F4']}}` would
|
|
||||||
become: `{'1/1/1': {'1/1/2': ['1/1/3', '1/1/4']}}`
|
|
||||||
|
|
||||||
:param encoded_dict: Dictionary to be decoded.
|
|
||||||
:param decode_keys: (Optional) Enable/disable decoding of dict keys.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def decode_value(value: Any, _decode_keys: bool) -> Any:
|
|
||||||
"""
|
|
||||||
Handle URL decoding of any supported value type.
|
|
||||||
"""
|
|
||||||
# Decode string values.
|
|
||||||
if isinstance(value, str):
|
|
||||||
return urllib.parse.unquote(value)
|
|
||||||
# Recursively decode each list item.
|
|
||||||
elif isinstance(value, list):
|
|
||||||
return [decode_value(v, _decode_keys) for v in value]
|
|
||||||
# Recursively decode each tuple item.
|
|
||||||
elif isinstance(value, Tuple):
|
|
||||||
return tuple(decode_value(v, _decode_keys) for v in value)
|
|
||||||
# Recursively decode each dict key/value pair.
|
|
||||||
elif isinstance(value, dict):
|
|
||||||
# Don't decode keys, if `decode_keys` is false.
|
|
||||||
if not _decode_keys:
|
|
||||||
return {k: decode_value(v, _decode_keys) for k, v in value.items()}
|
|
||||||
return {urllib.parse.unquote(k): decode_value(v, _decode_keys) for k, v in value.items()}
|
|
||||||
return value
|
|
||||||
|
|
||||||
if not decode_keys:
|
|
||||||
# Don't decode keys, if `decode_keys` is false.
|
|
||||||
return {k: decode_value(v, decode_keys) for k, v in encoded_dict.items()}
|
|
||||||
|
|
||||||
return {urllib.parse.unquote(k): decode_value(v, decode_keys) for k, v in encoded_dict.items()}
|
|
||||||
|
|
||||||
|
|
||||||
def array_to_string(array):
|
def array_to_string(array):
|
||||||
"""
|
"""
|
||||||
Generate an efficient, human-friendly string from a set of integers. Intended for use with ArrayField.
|
Generate an efficient, human-friendly string from a set of integers. Intended for use with ArrayField.
|
||||||
|
Reference in New Issue
Block a user