mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Reference DEFAULT_USER_PREFERENCES for undefined preferences
This commit is contained in:
parent
01997efcbe
commit
cb6342c874
@ -80,13 +80,25 @@ class UserConfig(models.Model):
|
|||||||
keys = path.split('.')
|
keys = path.split('.')
|
||||||
|
|
||||||
# Iterate down the hierarchy, returning the default value if any invalid key is encountered
|
# Iterate down the hierarchy, returning the default value if any invalid key is encountered
|
||||||
for key in keys:
|
try:
|
||||||
if type(d) is dict and key in d:
|
for key in keys:
|
||||||
d = d.get(key)
|
d = d.get(key)
|
||||||
else:
|
return d
|
||||||
return default
|
except (AttributeError, KeyError):
|
||||||
|
pass
|
||||||
|
|
||||||
return d
|
# If the key is not found in the user's config, check for an application-wide default
|
||||||
|
config = get_config()
|
||||||
|
d = config.DEFAULT_USER_PREFERENCES
|
||||||
|
try:
|
||||||
|
for key in keys:
|
||||||
|
d = d.get(key)
|
||||||
|
return d
|
||||||
|
except (AttributeError, KeyError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Finally, return the specified default value (if any)
|
||||||
|
return default
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user