mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
#19739: Include tab character as CSV delimiter choice
This commit is contained in:
parent
e4e4bb6bd5
commit
9cf023a0c6
@ -66,4 +66,5 @@ CSV_DELIMITERS = {
|
||||
'comma': ',',
|
||||
'semicolon': ';',
|
||||
'pipe': '|',
|
||||
'tab': '\t',
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.constants import CSV_DELIMITERS
|
||||
from netbox.registry import registry
|
||||
from users.preferences import UserPreference
|
||||
from utilities.paginator import EnhancedPaginator
|
||||
@ -12,6 +13,16 @@ def get_page_lengths():
|
||||
]
|
||||
|
||||
|
||||
def get_csv_delimiters():
|
||||
choices = []
|
||||
for k, v in CSV_DELIMITERS.items():
|
||||
label = _(k.title())
|
||||
if v.strip():
|
||||
label = f'{label} ({v})'
|
||||
choices.append((k, label))
|
||||
return choices
|
||||
|
||||
|
||||
PREFERENCES = {
|
||||
|
||||
# User interface
|
||||
@ -74,11 +85,7 @@ PREFERENCES = {
|
||||
),
|
||||
'csv_delimiter': UserPreference(
|
||||
label=_('CSV delimiter'),
|
||||
choices=(
|
||||
('comma', 'Comma (,)'),
|
||||
('semicolon', 'Semicolon (;)'),
|
||||
('pipe', 'Pipe (|)'),
|
||||
),
|
||||
choices=get_csv_delimiters(),
|
||||
default='comma',
|
||||
description=_('The character used to separate fields in CSV data')
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user