mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Move choice sets from utilities.choices to netbox.choices
This commit is contained in:
parent
99144031b7
commit
a9bb4c5c3e
@ -49,8 +49,8 @@ menu_items = (item1, item2, item3)
|
|||||||
Each menu item represents a link and (optionally) a set of buttons comprising one entry in NetBox's navigation menu. Menu items are defined as PluginMenuItem instances. An example is shown below.
|
Each menu item represents a link and (optionally) a set of buttons comprising one entry in NetBox's navigation menu. Menu items are defined as PluginMenuItem instances. An example is shown below.
|
||||||
|
|
||||||
```python title="navigation.py"
|
```python title="navigation.py"
|
||||||
|
from netbox.choices import ButtonColorChoices
|
||||||
from netbox.plugins import PluginMenuButton, PluginMenuItem
|
from netbox.plugins import PluginMenuButton, PluginMenuItem
|
||||||
from utilities.choices import ButtonColorChoices
|
|
||||||
|
|
||||||
item1 = PluginMenuItem(
|
item1 = PluginMenuItem(
|
||||||
link='plugins:myplugin:myview',
|
link='plugins:myplugin:myview',
|
||||||
|
@ -10,12 +10,12 @@ from extras.filtersets import LocalConfigContextFilterSet
|
|||||||
from extras.models import ConfigTemplate
|
from extras.models import ConfigTemplate
|
||||||
from ipam.filtersets import PrimaryIPFilterSet
|
from ipam.filtersets import PrimaryIPFilterSet
|
||||||
from ipam.models import ASN, IPAddress, VRF
|
from ipam.models import ASN, IPAddress, VRF
|
||||||
|
from netbox.choices import ColorChoices
|
||||||
from netbox.filtersets import (
|
from netbox.filtersets import (
|
||||||
BaseFilterSet, ChangeLoggedModelFilterSet, OrganizationalModelFilterSet, NetBoxModelFilterSet,
|
BaseFilterSet, ChangeLoggedModelFilterSet, OrganizationalModelFilterSet, NetBoxModelFilterSet,
|
||||||
)
|
)
|
||||||
from tenancy.filtersets import TenancyFilterSet, ContactModelFilterSet
|
from tenancy.filtersets import TenancyFilterSet, ContactModelFilterSet
|
||||||
from tenancy.models import *
|
from tenancy.models import *
|
||||||
from utilities.choices import ColorChoices
|
|
||||||
from utilities.filters import (
|
from utilities.filters import (
|
||||||
ContentTypeFilter, MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter, MultiValueWWNFilter,
|
ContentTypeFilter, MultiValueCharFilter, MultiValueMACAddressFilter, MultiValueNumberFilter, MultiValueWWNFilter,
|
||||||
NumericArrayFilter, TreeNodeMultipleChoiceFilter,
|
NumericArrayFilter, TreeNodeMultipleChoiceFilter,
|
||||||
|
@ -12,8 +12,8 @@ from mptt.models import MPTTModel, TreeForeignKey
|
|||||||
from dcim.choices import *
|
from dcim.choices import *
|
||||||
from dcim.constants import *
|
from dcim.constants import *
|
||||||
from dcim.fields import MACAddressField, WWNField
|
from dcim.fields import MACAddressField, WWNField
|
||||||
|
from netbox.choices import ColorChoices
|
||||||
from netbox.models import OrganizationalModel, NetBoxModel
|
from netbox.models import OrganizationalModel, NetBoxModel
|
||||||
from utilities.choices import ColorChoices
|
|
||||||
from utilities.fields import ColorField, NaturalOrderingField
|
from utilities.fields import ColorField, NaturalOrderingField
|
||||||
from utilities.mptt import TreeManager
|
from utilities.mptt import TreeManager
|
||||||
from utilities.ordering import naturalize_interface
|
from utilities.ordering import naturalize_interface
|
||||||
|
@ -18,10 +18,10 @@ from dcim.choices import *
|
|||||||
from dcim.constants import *
|
from dcim.constants import *
|
||||||
from extras.models import ConfigContextModel, CustomField
|
from extras.models import ConfigContextModel, CustomField
|
||||||
from extras.querysets import ConfigContextModelQuerySet
|
from extras.querysets import ConfigContextModelQuerySet
|
||||||
|
from netbox.choices import ColorChoices
|
||||||
from netbox.config import ConfigItem
|
from netbox.config import ConfigItem
|
||||||
from netbox.models import OrganizationalModel, PrimaryModel
|
from netbox.models import OrganizationalModel, PrimaryModel
|
||||||
from netbox.models.features import ContactsMixin, ImageAttachmentsMixin
|
from netbox.models.features import ContactsMixin, ImageAttachmentsMixin
|
||||||
from utilities.choices import ColorChoices
|
|
||||||
from utilities.fields import ColorField, CounterCacheField, NaturalOrderingField
|
from utilities.fields import ColorField, CounterCacheField, NaturalOrderingField
|
||||||
from utilities.tracking import TrackingModelMixin
|
from utilities.tracking import TrackingModelMixin
|
||||||
from .device_components import *
|
from .device_components import *
|
||||||
|
@ -14,9 +14,9 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from dcim.choices import *
|
from dcim.choices import *
|
||||||
from dcim.constants import *
|
from dcim.constants import *
|
||||||
from dcim.svg import RackElevationSVG
|
from dcim.svg import RackElevationSVG
|
||||||
|
from netbox.choices import ColorChoices
|
||||||
from netbox.models import OrganizationalModel, PrimaryModel
|
from netbox.models import OrganizationalModel, PrimaryModel
|
||||||
from netbox.models.features import ContactsMixin, ImageAttachmentsMixin
|
from netbox.models.features import ContactsMixin, ImageAttachmentsMixin
|
||||||
from utilities.choices import ColorChoices
|
|
||||||
from utilities.fields import ColorField, NaturalOrderingField
|
from utilities.fields import ColorField, NaturalOrderingField
|
||||||
from utilities.utils import array_to_string, drange, to_grams
|
from utilities.utils import array_to_string, drange, to_grams
|
||||||
from .device_components import PowerPort
|
from .device_components import PowerPort
|
||||||
|
@ -6,13 +6,12 @@ from dcim.choices import *
|
|||||||
from dcim.filtersets import *
|
from dcim.filtersets import *
|
||||||
from dcim.models import *
|
from dcim.models import *
|
||||||
from ipam.models import ASN, IPAddress, RIR, VRF
|
from ipam.models import ASN, IPAddress, RIR, VRF
|
||||||
|
from netbox.choices import ColorChoices
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from utilities.choices import ColorChoices
|
|
||||||
from utilities.testing import ChangeLoggedFilterSetTests, create_test_device
|
from utilities.testing import ChangeLoggedFilterSetTests, create_test_device
|
||||||
from virtualization.models import Cluster, ClusterType
|
from virtualization.models import Cluster, ClusterType
|
||||||
from wireless.choices import WirelessChannelChoices, WirelessRoleChoices
|
from wireless.choices import WirelessChannelChoices, WirelessRoleChoices
|
||||||
|
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,12 +11,11 @@ from dcim.choices import *
|
|||||||
from dcim.constants import *
|
from dcim.constants import *
|
||||||
from dcim.models import *
|
from dcim.models import *
|
||||||
from ipam.models import ASN, RIR, VLAN, VRF
|
from ipam.models import ASN, RIR, VLAN, VRF
|
||||||
|
from netbox.choices import CSVDelimiterChoices, ImportFormatChoices
|
||||||
from tenancy.models import Tenant
|
from tenancy.models import Tenant
|
||||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices
|
|
||||||
from utilities.testing import ViewTestCases, create_tags, create_test_device, post_data
|
from utilities.testing import ViewTestCases, create_tags, create_test_device, post_data
|
||||||
from wireless.models import WirelessLAN
|
from wireless.models import WirelessLAN
|
||||||
|
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@ import logging
|
|||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from utilities.choices import ButtonColorChoices, ChoiceSet
|
from netbox.choices import ButtonColorChoices
|
||||||
|
from utilities.choices import ChoiceSet
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -14,7 +14,7 @@ from django.utils.translation import gettext as _
|
|||||||
|
|
||||||
from core.models import ObjectType
|
from core.models import ObjectType
|
||||||
from extras.choices import BookmarkOrderingChoices
|
from extras.choices import BookmarkOrderingChoices
|
||||||
from utilities.choices import ButtonColorChoices
|
from netbox.choices import ButtonColorChoices
|
||||||
from utilities.permissions import get_permission_for_model
|
from utilities.permissions import get_permission_for_model
|
||||||
from utilities.templatetags.builtins.filters import render_markdown
|
from utilities.templatetags.builtins.filters import render_markdown
|
||||||
from utilities.utils import content_type_identifier, content_type_name, dict_to_querydict, get_viewname
|
from utilities.utils import content_type_identifier, content_type_name, dict_to_querydict, get_viewname
|
||||||
|
@ -5,9 +5,9 @@ from django.utils.text import slugify
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from taggit.models import TagBase, GenericTaggedItemBase
|
from taggit.models import TagBase, GenericTaggedItemBase
|
||||||
|
|
||||||
|
from netbox.choices import ColorChoices
|
||||||
from netbox.models import ChangeLoggedModel
|
from netbox.models import ChangeLoggedModel
|
||||||
from netbox.models.features import CloningMixin, ExportTemplatesMixin
|
from netbox.models.features import CloningMixin, ExportTemplatesMixin
|
||||||
from utilities.choices import ColorChoices
|
|
||||||
from utilities.fields import ColorField
|
from utilities.fields import ColorField
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
@ -5,7 +5,7 @@ from circuits.api.serializers import ProviderSerializer
|
|||||||
from circuits.forms import ProviderForm
|
from circuits.forms import ProviderForm
|
||||||
from circuits.models import Provider
|
from circuits.models import Provider
|
||||||
from ipam.models import ASN, RIR
|
from ipam.models import ASN, RIR
|
||||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices
|
from netbox.choices import CSVDelimiterChoices, ImportFormatChoices
|
||||||
from utilities.testing import APITestCase, ModelViewTestCase, create_tags, post_data
|
from utilities.testing import APITestCase, ModelViewTestCase, create_tags, post_data
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from dcim.models import Manufacturer, Rack, Site
|
|||||||
from extras.choices import *
|
from extras.choices import *
|
||||||
from extras.models import CustomField, CustomFieldChoiceSet
|
from extras.models import CustomField, CustomFieldChoiceSet
|
||||||
from ipam.models import VLAN
|
from ipam.models import VLAN
|
||||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices
|
from netbox.choices import CSVDelimiterChoices, ImportFormatChoices
|
||||||
from utilities.testing import APITestCase, TestCase
|
from utilities.testing import APITestCase, TestCase
|
||||||
from virtualization.models import VirtualMachine
|
from virtualization.models import VirtualMachine
|
||||||
|
|
||||||
|
162
netbox/netbox/choices.py
Normal file
162
netbox/netbox/choices.py
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from utilities.choices import ChoiceSet
|
||||||
|
from utilities.constants import CSV_DELIMITERS
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'ButtonColorChoices',
|
||||||
|
'ColorChoices',
|
||||||
|
'CSVDelimiterChoices',
|
||||||
|
'ImportFormatChoices',
|
||||||
|
'ImportMethodChoices',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generic color choices
|
||||||
|
#
|
||||||
|
|
||||||
|
class ColorChoices(ChoiceSet):
|
||||||
|
COLOR_DARK_RED = 'aa1409'
|
||||||
|
COLOR_RED = 'f44336'
|
||||||
|
COLOR_PINK = 'e91e63'
|
||||||
|
COLOR_ROSE = 'ffe4e1'
|
||||||
|
COLOR_FUCHSIA = 'ff66ff'
|
||||||
|
COLOR_PURPLE = '9c27b0'
|
||||||
|
COLOR_DARK_PURPLE = '673ab7'
|
||||||
|
COLOR_INDIGO = '3f51b5'
|
||||||
|
COLOR_BLUE = '2196f3'
|
||||||
|
COLOR_LIGHT_BLUE = '03a9f4'
|
||||||
|
COLOR_CYAN = '00bcd4'
|
||||||
|
COLOR_TEAL = '009688'
|
||||||
|
COLOR_AQUA = '00ffff'
|
||||||
|
COLOR_DARK_GREEN = '2f6a31'
|
||||||
|
COLOR_GREEN = '4caf50'
|
||||||
|
COLOR_LIGHT_GREEN = '8bc34a'
|
||||||
|
COLOR_LIME = 'cddc39'
|
||||||
|
COLOR_YELLOW = 'ffeb3b'
|
||||||
|
COLOR_AMBER = 'ffc107'
|
||||||
|
COLOR_ORANGE = 'ff9800'
|
||||||
|
COLOR_DARK_ORANGE = 'ff5722'
|
||||||
|
COLOR_BROWN = '795548'
|
||||||
|
COLOR_LIGHT_GREY = 'c0c0c0'
|
||||||
|
COLOR_GREY = '9e9e9e'
|
||||||
|
COLOR_DARK_GREY = '607d8b'
|
||||||
|
COLOR_BLACK = '111111'
|
||||||
|
COLOR_WHITE = 'ffffff'
|
||||||
|
|
||||||
|
CHOICES = (
|
||||||
|
(COLOR_DARK_RED, _('Dark Red')),
|
||||||
|
(COLOR_RED, _('Red')),
|
||||||
|
(COLOR_PINK, _('Pink')),
|
||||||
|
(COLOR_ROSE, _('Rose')),
|
||||||
|
(COLOR_FUCHSIA, _('Fuchsia')),
|
||||||
|
(COLOR_PURPLE, _('Purple')),
|
||||||
|
(COLOR_DARK_PURPLE, _('Dark Purple')),
|
||||||
|
(COLOR_INDIGO, _('Indigo')),
|
||||||
|
(COLOR_BLUE, _('Blue')),
|
||||||
|
(COLOR_LIGHT_BLUE, _('Light Blue')),
|
||||||
|
(COLOR_CYAN, _('Cyan')),
|
||||||
|
(COLOR_TEAL, _('Teal')),
|
||||||
|
(COLOR_AQUA, _('Aqua')),
|
||||||
|
(COLOR_DARK_GREEN, _('Dark Green')),
|
||||||
|
(COLOR_GREEN, _('Green')),
|
||||||
|
(COLOR_LIGHT_GREEN, _('Light Green')),
|
||||||
|
(COLOR_LIME, _('Lime')),
|
||||||
|
(COLOR_YELLOW, _('Yellow')),
|
||||||
|
(COLOR_AMBER, _('Amber')),
|
||||||
|
(COLOR_ORANGE, _('Orange')),
|
||||||
|
(COLOR_DARK_ORANGE, _('Dark Orange')),
|
||||||
|
(COLOR_BROWN, _('Brown')),
|
||||||
|
(COLOR_LIGHT_GREY, _('Light Grey')),
|
||||||
|
(COLOR_GREY, _('Grey')),
|
||||||
|
(COLOR_DARK_GREY, _('Dark Grey')),
|
||||||
|
(COLOR_BLACK, _('Black')),
|
||||||
|
(COLOR_WHITE, _('White')),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Button color choices
|
||||||
|
#
|
||||||
|
|
||||||
|
class ButtonColorChoices(ChoiceSet):
|
||||||
|
"""
|
||||||
|
Map standard button color choices to Bootstrap 3 button classes
|
||||||
|
"""
|
||||||
|
DEFAULT = 'outline-dark'
|
||||||
|
BLUE = 'blue'
|
||||||
|
INDIGO = 'indigo'
|
||||||
|
PURPLE = 'purple'
|
||||||
|
PINK = 'pink'
|
||||||
|
RED = 'red'
|
||||||
|
ORANGE = 'orange'
|
||||||
|
YELLOW = 'yellow'
|
||||||
|
GREEN = 'green'
|
||||||
|
TEAL = 'teal'
|
||||||
|
CYAN = 'cyan'
|
||||||
|
GRAY = 'gray'
|
||||||
|
GREY = 'gray' # Backward compatability for <3.2
|
||||||
|
BLACK = 'black'
|
||||||
|
WHITE = 'white'
|
||||||
|
|
||||||
|
CHOICES = (
|
||||||
|
(DEFAULT, _('Default')),
|
||||||
|
(BLUE, _('Blue')),
|
||||||
|
(INDIGO, _('Indigo')),
|
||||||
|
(PURPLE, _('Purple')),
|
||||||
|
(PINK, _('Pink')),
|
||||||
|
(RED, _('Red')),
|
||||||
|
(ORANGE, _('Orange')),
|
||||||
|
(YELLOW, _('Yellow')),
|
||||||
|
(GREEN, _('Green')),
|
||||||
|
(TEAL, _('Teal')),
|
||||||
|
(CYAN, _('Cyan')),
|
||||||
|
(GRAY, _('Gray')),
|
||||||
|
(BLACK, _('Black')),
|
||||||
|
(WHITE, _('White')),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Import Choices
|
||||||
|
#
|
||||||
|
|
||||||
|
class ImportMethodChoices(ChoiceSet):
|
||||||
|
DIRECT = 'direct'
|
||||||
|
UPLOAD = 'upload'
|
||||||
|
DATA_FILE = 'datafile'
|
||||||
|
|
||||||
|
CHOICES = [
|
||||||
|
(DIRECT, _('Direct')),
|
||||||
|
(UPLOAD, _('Upload')),
|
||||||
|
(DATA_FILE, _('Data file')),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ImportFormatChoices(ChoiceSet):
|
||||||
|
AUTO = 'auto'
|
||||||
|
CSV = 'csv'
|
||||||
|
JSON = 'json'
|
||||||
|
YAML = 'yaml'
|
||||||
|
|
||||||
|
CHOICES = [
|
||||||
|
(AUTO, _('Auto-detect')),
|
||||||
|
(CSV, 'CSV'),
|
||||||
|
(JSON, 'JSON'),
|
||||||
|
(YAML, 'YAML'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class CSVDelimiterChoices(ChoiceSet):
|
||||||
|
AUTO = 'auto'
|
||||||
|
COMMA = CSV_DELIMITERS['comma']
|
||||||
|
SEMICOLON = CSV_DELIMITERS['semicolon']
|
||||||
|
TAB = CSV_DELIMITERS['tab']
|
||||||
|
|
||||||
|
CHOICES = [
|
||||||
|
(AUTO, _('Auto-detect')),
|
||||||
|
(COMMA, _('Comma')),
|
||||||
|
(SEMICOLON, _('Semicolon')),
|
||||||
|
(TAB, _('Tab')),
|
||||||
|
]
|
@ -1,8 +1,6 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Sequence, Optional
|
from typing import Sequence, Optional
|
||||||
|
|
||||||
from utilities.choices import ButtonColorChoices
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'get_model_item',
|
'get_model_item',
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from netbox.registry import registry
|
from netbox.registry import registry
|
||||||
from utilities.choices import ButtonColorChoices
|
|
||||||
from . import *
|
from . import *
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
from netbox.navigation import MenuGroup
|
|
||||||
from utilities.choices import ButtonColorChoices
|
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
from netbox.choices import ButtonColorChoices
|
||||||
|
from netbox.navigation import MenuGroup
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'PluginMenu',
|
'PluginMenu',
|
||||||
'PluginMenuButton',
|
'PluginMenuButton',
|
||||||
|
@ -2,8 +2,8 @@ from django.test import override_settings
|
|||||||
|
|
||||||
from core.models import ObjectType
|
from core.models import ObjectType
|
||||||
from dcim.models import *
|
from dcim.models import *
|
||||||
|
from netbox.choices import CSVDelimiterChoices, ImportFormatChoices
|
||||||
from users.models import ObjectPermission
|
from users.models import ObjectPermission
|
||||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices
|
|
||||||
from utilities.testing import ModelViewTestCase, create_tags
|
from utilities.testing import ModelViewTestCase, create_tags
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from .constants import CSV_DELIMITERS
|
__all__ = (
|
||||||
|
'ChoiceSet',
|
||||||
|
'unpack_grouped_choices',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ChoiceSetMeta(type):
|
class ChoiceSetMeta(type):
|
||||||
@ -96,153 +99,3 @@ def unpack_grouped_choices(choices):
|
|||||||
else:
|
else:
|
||||||
unpacked_choices.append((key, value))
|
unpacked_choices.append((key, value))
|
||||||
return unpacked_choices
|
return unpacked_choices
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Generic color choices
|
|
||||||
#
|
|
||||||
|
|
||||||
class ColorChoices(ChoiceSet):
|
|
||||||
COLOR_DARK_RED = 'aa1409'
|
|
||||||
COLOR_RED = 'f44336'
|
|
||||||
COLOR_PINK = 'e91e63'
|
|
||||||
COLOR_ROSE = 'ffe4e1'
|
|
||||||
COLOR_FUCHSIA = 'ff66ff'
|
|
||||||
COLOR_PURPLE = '9c27b0'
|
|
||||||
COLOR_DARK_PURPLE = '673ab7'
|
|
||||||
COLOR_INDIGO = '3f51b5'
|
|
||||||
COLOR_BLUE = '2196f3'
|
|
||||||
COLOR_LIGHT_BLUE = '03a9f4'
|
|
||||||
COLOR_CYAN = '00bcd4'
|
|
||||||
COLOR_TEAL = '009688'
|
|
||||||
COLOR_AQUA = '00ffff'
|
|
||||||
COLOR_DARK_GREEN = '2f6a31'
|
|
||||||
COLOR_GREEN = '4caf50'
|
|
||||||
COLOR_LIGHT_GREEN = '8bc34a'
|
|
||||||
COLOR_LIME = 'cddc39'
|
|
||||||
COLOR_YELLOW = 'ffeb3b'
|
|
||||||
COLOR_AMBER = 'ffc107'
|
|
||||||
COLOR_ORANGE = 'ff9800'
|
|
||||||
COLOR_DARK_ORANGE = 'ff5722'
|
|
||||||
COLOR_BROWN = '795548'
|
|
||||||
COLOR_LIGHT_GREY = 'c0c0c0'
|
|
||||||
COLOR_GREY = '9e9e9e'
|
|
||||||
COLOR_DARK_GREY = '607d8b'
|
|
||||||
COLOR_BLACK = '111111'
|
|
||||||
COLOR_WHITE = 'ffffff'
|
|
||||||
|
|
||||||
CHOICES = (
|
|
||||||
(COLOR_DARK_RED, _('Dark Red')),
|
|
||||||
(COLOR_RED, _('Red')),
|
|
||||||
(COLOR_PINK, _('Pink')),
|
|
||||||
(COLOR_ROSE, _('Rose')),
|
|
||||||
(COLOR_FUCHSIA, _('Fuchsia')),
|
|
||||||
(COLOR_PURPLE, _('Purple')),
|
|
||||||
(COLOR_DARK_PURPLE, _('Dark Purple')),
|
|
||||||
(COLOR_INDIGO, _('Indigo')),
|
|
||||||
(COLOR_BLUE, _('Blue')),
|
|
||||||
(COLOR_LIGHT_BLUE, _('Light Blue')),
|
|
||||||
(COLOR_CYAN, _('Cyan')),
|
|
||||||
(COLOR_TEAL, _('Teal')),
|
|
||||||
(COLOR_AQUA, _('Aqua')),
|
|
||||||
(COLOR_DARK_GREEN, _('Dark Green')),
|
|
||||||
(COLOR_GREEN, _('Green')),
|
|
||||||
(COLOR_LIGHT_GREEN, _('Light Green')),
|
|
||||||
(COLOR_LIME, _('Lime')),
|
|
||||||
(COLOR_YELLOW, _('Yellow')),
|
|
||||||
(COLOR_AMBER, _('Amber')),
|
|
||||||
(COLOR_ORANGE, _('Orange')),
|
|
||||||
(COLOR_DARK_ORANGE, _('Dark Orange')),
|
|
||||||
(COLOR_BROWN, _('Brown')),
|
|
||||||
(COLOR_LIGHT_GREY, _('Light Grey')),
|
|
||||||
(COLOR_GREY, _('Grey')),
|
|
||||||
(COLOR_DARK_GREY, _('Dark Grey')),
|
|
||||||
(COLOR_BLACK, _('Black')),
|
|
||||||
(COLOR_WHITE, _('White')),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Button color choices
|
|
||||||
#
|
|
||||||
|
|
||||||
class ButtonColorChoices(ChoiceSet):
|
|
||||||
"""
|
|
||||||
Map standard button color choices to Bootstrap 3 button classes
|
|
||||||
"""
|
|
||||||
DEFAULT = 'outline-dark'
|
|
||||||
BLUE = 'blue'
|
|
||||||
INDIGO = 'indigo'
|
|
||||||
PURPLE = 'purple'
|
|
||||||
PINK = 'pink'
|
|
||||||
RED = 'red'
|
|
||||||
ORANGE = 'orange'
|
|
||||||
YELLOW = 'yellow'
|
|
||||||
GREEN = 'green'
|
|
||||||
TEAL = 'teal'
|
|
||||||
CYAN = 'cyan'
|
|
||||||
GRAY = 'gray'
|
|
||||||
GREY = 'gray' # Backward compatability for <3.2
|
|
||||||
BLACK = 'black'
|
|
||||||
WHITE = 'white'
|
|
||||||
|
|
||||||
CHOICES = (
|
|
||||||
(DEFAULT, _('Default')),
|
|
||||||
(BLUE, _('Blue')),
|
|
||||||
(INDIGO, _('Indigo')),
|
|
||||||
(PURPLE, _('Purple')),
|
|
||||||
(PINK, _('Pink')),
|
|
||||||
(RED, _('Red')),
|
|
||||||
(ORANGE, _('Orange')),
|
|
||||||
(YELLOW, _('Yellow')),
|
|
||||||
(GREEN, _('Green')),
|
|
||||||
(TEAL, _('Teal')),
|
|
||||||
(CYAN, _('Cyan')),
|
|
||||||
(GRAY, _('Gray')),
|
|
||||||
(BLACK, _('Black')),
|
|
||||||
(WHITE, _('White')),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Import Choices
|
|
||||||
#
|
|
||||||
|
|
||||||
class ImportMethodChoices(ChoiceSet):
|
|
||||||
DIRECT = 'direct'
|
|
||||||
UPLOAD = 'upload'
|
|
||||||
DATA_FILE = 'datafile'
|
|
||||||
|
|
||||||
CHOICES = [
|
|
||||||
(DIRECT, _('Direct')),
|
|
||||||
(UPLOAD, _('Upload')),
|
|
||||||
(DATA_FILE, _('Data file')),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class ImportFormatChoices(ChoiceSet):
|
|
||||||
AUTO = 'auto'
|
|
||||||
CSV = 'csv'
|
|
||||||
JSON = 'json'
|
|
||||||
YAML = 'yaml'
|
|
||||||
|
|
||||||
CHOICES = [
|
|
||||||
(AUTO, _('Auto-detect')),
|
|
||||||
(CSV, 'CSV'),
|
|
||||||
(JSON, 'JSON'),
|
|
||||||
(YAML, 'YAML'),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class CSVDelimiterChoices(ChoiceSet):
|
|
||||||
AUTO = 'auto'
|
|
||||||
COMMA = CSV_DELIMITERS['comma']
|
|
||||||
SEMICOLON = CSV_DELIMITERS['semicolon']
|
|
||||||
TAB = CSV_DELIMITERS['tab']
|
|
||||||
|
|
||||||
CHOICES = [
|
|
||||||
(AUTO, _('Auto-detect')),
|
|
||||||
(COMMA, _('Comma')),
|
|
||||||
(SEMICOLON, _('Semicolon')),
|
|
||||||
(TAB, _('Tab')),
|
|
||||||
]
|
|
||||||
|
@ -7,7 +7,7 @@ from django import forms
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from core.forms.mixins import SyncedDataMixin
|
from core.forms.mixins import SyncedDataMixin
|
||||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices, ImportMethodChoices
|
from netbox.choices import CSVDelimiterChoices, ImportFormatChoices, ImportMethodChoices
|
||||||
from utilities.constants import CSV_DELIMITERS
|
from utilities.constants import CSV_DELIMITERS
|
||||||
from utilities.forms.utils import parse_csv
|
from utilities.forms.utils import parse_csv
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from utilities.choices import ColorChoices
|
from netbox.choices import ColorChoices
|
||||||
from ..utils import add_blank_choice
|
from ..utils import add_blank_choice
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
@ -11,9 +11,9 @@ from django.utils.translation import gettext as _
|
|||||||
from core.models import ObjectType
|
from core.models import ObjectType
|
||||||
from extras.choices import ObjectChangeActionChoices
|
from extras.choices import ObjectChangeActionChoices
|
||||||
from extras.models import ObjectChange
|
from extras.models import ObjectChange
|
||||||
|
from netbox.choices import CSVDelimiterChoices, ImportFormatChoices
|
||||||
from netbox.models.features import ChangeLoggingMixin
|
from netbox.models.features import ChangeLoggingMixin
|
||||||
from users.models import ObjectPermission
|
from users.models import ObjectPermission
|
||||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices
|
|
||||||
from .base import ModelTestCase
|
from .base import ModelTestCase
|
||||||
from .utils import disable_warnings, post_data
|
from .utils import disable_warnings, post_data
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from utilities.choices import ImportFormatChoices
|
from netbox.choices import ImportFormatChoices
|
||||||
from utilities.forms.bulk_import import BulkImportForm
|
from utilities.forms.bulk_import import BulkImportForm
|
||||||
from utilities.forms.forms import BulkRenameForm
|
from utilities.forms.forms import BulkRenameForm
|
||||||
from utilities.forms.utils import expand_alphanumeric_pattern, expand_ipaddress_pattern
|
from utilities.forms.utils import expand_alphanumeric_pattern, expand_ipaddress_pattern
|
||||||
|
Loading…
Reference in New Issue
Block a user