mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Enable plugins to define user preferences
This commit is contained in:
@ -1,12 +1,3 @@
|
||||
from utilities.paginator import EnhancedPaginator
|
||||
|
||||
|
||||
def get_page_lengths():
|
||||
return [
|
||||
(v, str(v)) for v in EnhancedPaginator.default_page_lengths
|
||||
]
|
||||
|
||||
|
||||
class UserPreference:
|
||||
|
||||
def __init__(self, label, choices, default=None, description='', coerce=lambda x: x):
|
||||
@ -15,33 +6,3 @@ class UserPreference:
|
||||
self.default = default if default is not None else choices[0]
|
||||
self.description = description
|
||||
self.coerce = coerce
|
||||
|
||||
|
||||
PREFERENCES = {
|
||||
|
||||
# User interface
|
||||
'ui.colormode': UserPreference(
|
||||
label='Color mode',
|
||||
choices=(
|
||||
('light', 'Light'),
|
||||
('dark', 'Dark'),
|
||||
),
|
||||
default='light',
|
||||
),
|
||||
'pagination.per_page': UserPreference(
|
||||
label='Page length',
|
||||
choices=get_page_lengths(),
|
||||
description='The number of objects to display per page',
|
||||
coerce=lambda x: int(x)
|
||||
),
|
||||
|
||||
# Miscellaneous
|
||||
'data_format': UserPreference(
|
||||
label='Data format',
|
||||
choices=(
|
||||
('json', 'JSON'),
|
||||
('yaml', 'YAML'),
|
||||
),
|
||||
),
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user