netbox/netbox/users/preferences.py
Anton 1feb3742e2
add ENABLE_TRANSLATION setting to optionally turn translation off (#16096)
* add USE_I18N setting

* change setting name to ENABLE_TRANSLATION

* raise a warning in the UI when translation is disabled

* Misc cleanup

* Rename to TRANSLATION_ENABLED for consistency with other settings

---------

Co-authored-by: Anton Myasnikov <anton.myasnikov@nordigy.ru>
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-05-14 09:21:00 -04:00

12 lines
414 B
Python

class UserPreference:
"""
Represents a configurable user preference.
"""
def __init__(self, label, choices, default=None, description='', coerce=lambda x: x, warning=''):
self.label = label
self.choices = choices
self.default = default if default is not None else choices[0]
self.description = description
self.coerce = coerce
self.warning = warning