10300 initial translation support use gettext

This commit is contained in:
Arthur
2022-11-03 11:58:26 -07:00
committed by Jeremy Stretch
parent 2cc2d2cc37
commit 6eba5d4d96
67 changed files with 1192 additions and 1134 deletions

View File

@@ -3,6 +3,7 @@ import netaddr
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.utils.translation import gettext as _
from netaddr.core import AddrFormatError
from dcim.models import Device, Interface, Region, Site, SiteGroup
@@ -41,24 +42,24 @@ class VRFFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
import_target_id = django_filters.ModelMultipleChoiceFilter(
field_name='import_targets',
queryset=RouteTarget.objects.all(),
label='Import target',
label=_('Import target'),
)
import_target = django_filters.ModelMultipleChoiceFilter(
field_name='import_targets__name',
queryset=RouteTarget.objects.all(),
to_field_name='name',
label='Import target (name)',
label=_('Import target (name)'),
)
export_target_id = django_filters.ModelMultipleChoiceFilter(
field_name='export_targets',
queryset=RouteTarget.objects.all(),
label='Export target',
label=_('Export target'),
)
export_target = django_filters.ModelMultipleChoiceFilter(
field_name='export_targets__name',
queryset=RouteTarget.objects.all(),
to_field_name='name',
label='Export target (name)',
label=_('Export target (name)'),
)
def search(self, queryset, name, value):
@@ -79,24 +80,24 @@ class RouteTargetFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
importing_vrf_id = django_filters.ModelMultipleChoiceFilter(
field_name='importing_vrfs',
queryset=VRF.objects.all(),
label='Importing VRF',
label=_('Importing VRF'),
)
importing_vrf = django_filters.ModelMultipleChoiceFilter(
field_name='importing_vrfs__rd',
queryset=VRF.objects.all(),
to_field_name='rd',
label='Import VRF (RD)',
label=_('Import VRF (RD)'),
)
exporting_vrf_id = django_filters.ModelMultipleChoiceFilter(
field_name='exporting_vrfs',
queryset=VRF.objects.all(),
label='Exporting VRF',
label=_('Exporting VRF'),
)
exporting_vrf = django_filters.ModelMultipleChoiceFilter(
field_name='exporting_vrfs__rd',
queryset=VRF.objects.all(),
to_field_name='rd',
label='Export VRF (RD)',
label=_('Export VRF (RD)'),
)
def search(self, queryset, name, value):
@@ -126,17 +127,17 @@ class AggregateFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
)
prefix = django_filters.CharFilter(
method='filter_prefix',
label='Prefix',
label=_('Prefix'),
)
rir_id = django_filters.ModelMultipleChoiceFilter(
queryset=RIR.objects.all(),
label='RIR (ID)',
label=_('RIR (ID)'),
)
rir = django_filters.ModelMultipleChoiceFilter(
field_name='rir__slug',
queryset=RIR.objects.all(),
to_field_name='slug',
label='RIR (slug)',
label=_('RIR (slug)'),
)
class Meta:
@@ -169,24 +170,24 @@ class AggregateFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
class ASNFilterSet(OrganizationalModelFilterSet, TenancyFilterSet):
rir_id = django_filters.ModelMultipleChoiceFilter(
queryset=RIR.objects.all(),
label='RIR (ID)',
label=_('RIR (ID)'),
)
rir = django_filters.ModelMultipleChoiceFilter(
field_name='rir__slug',
queryset=RIR.objects.all(),
to_field_name='slug',
label='RIR (slug)',
label=_('RIR (slug)'),
)
site_id = django_filters.ModelMultipleChoiceFilter(
field_name='sites',
queryset=Site.objects.all(),
label='Site (ID)',
label=_('Site (ID)'),
)
site = django_filters.ModelMultipleChoiceFilter(
field_name='sites__slug',
queryset=Site.objects.all(),
to_field_name='slug',
label='Site (slug)',
label=_('Site (slug)'),
)
class Meta:
@@ -218,19 +219,19 @@ class PrefixFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
)
prefix = MultiValueCharFilter(
method='filter_prefix',
label='Prefix',
label=_('Prefix'),
)
within = django_filters.CharFilter(
method='search_within',
label='Within prefix',
label=_('Within prefix'),
)
within_include = django_filters.CharFilter(
method='search_within_include',
label='Within and including prefix',
label=_('Within and including prefix'),
)
contains = django_filters.CharFilter(
method='search_contains',
label='Prefixes which contain this prefix or IP',
label=_('Prefixes which contain this prefix or IP'),
)
depth = MultiValueNumberFilter(
field_name='_depth'
@@ -252,78 +253,78 @@ class PrefixFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
)
vrf_id = django_filters.ModelMultipleChoiceFilter(
queryset=VRF.objects.all(),
label='VRF',
label=_('VRF'),
)
vrf = django_filters.ModelMultipleChoiceFilter(
field_name='vrf__rd',
queryset=VRF.objects.all(),
to_field_name='rd',
label='VRF (RD)',
label=_('VRF (RD)'),
)
present_in_vrf_id = django_filters.ModelChoiceFilter(
queryset=VRF.objects.all(),
method='filter_present_in_vrf',
label='VRF'
label=_('VRF')
)
present_in_vrf = django_filters.ModelChoiceFilter(
queryset=VRF.objects.all(),
method='filter_present_in_vrf',
to_field_name='rd',
label='VRF (RD)',
label=_('VRF (RD)'),
)
region_id = TreeNodeMultipleChoiceFilter(
queryset=Region.objects.all(),
field_name='site__region',
lookup_expr='in',
label='Region (ID)',
label=_('Region (ID)'),
)
region = TreeNodeMultipleChoiceFilter(
queryset=Region.objects.all(),
field_name='site__region',
lookup_expr='in',
to_field_name='slug',
label='Region (slug)',
label=_('Region (slug)'),
)
site_group_id = TreeNodeMultipleChoiceFilter(
queryset=SiteGroup.objects.all(),
field_name='site__group',
lookup_expr='in',
label='Site group (ID)',
label=_('Site group (ID)'),
)
site_group = TreeNodeMultipleChoiceFilter(
queryset=SiteGroup.objects.all(),
field_name='site__group',
lookup_expr='in',
to_field_name='slug',
label='Site group (slug)',
label=_('Site group (slug)'),
)
site_id = django_filters.ModelMultipleChoiceFilter(
queryset=Site.objects.all(),
label='Site (ID)',
label=_('Site (ID)'),
)
site = django_filters.ModelMultipleChoiceFilter(
field_name='site__slug',
queryset=Site.objects.all(),
to_field_name='slug',
label='Site (slug)',
label=_('Site (slug)'),
)
vlan_id = django_filters.ModelMultipleChoiceFilter(
queryset=VLAN.objects.all(),
label='VLAN (ID)',
label=_('VLAN (ID)'),
)
vlan_vid = django_filters.NumberFilter(
field_name='vlan__vid',
label='VLAN number (1-4094)',
label=_('VLAN number (1-4094)'),
)
role_id = django_filters.ModelMultipleChoiceFilter(
queryset=Role.objects.all(),
label='Role (ID)',
label=_('Role (ID)'),
)
role = django_filters.ModelMultipleChoiceFilter(
field_name='role__slug',
queryset=Role.objects.all(),
to_field_name='slug',
label='Role (slug)',
label=_('Role (slug)'),
)
status = django_filters.MultipleChoiceFilter(
choices=PrefixStatusChoices,
@@ -406,27 +407,27 @@ class IPRangeFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
)
contains = django_filters.CharFilter(
method='search_contains',
label='Ranges which contain this prefix or IP',
label=_('Ranges which contain this prefix or IP'),
)
vrf_id = django_filters.ModelMultipleChoiceFilter(
queryset=VRF.objects.all(),
label='VRF',
label=_('VRF'),
)
vrf = django_filters.ModelMultipleChoiceFilter(
field_name='vrf__rd',
queryset=VRF.objects.all(),
to_field_name='rd',
label='VRF (RD)',
label=_('VRF (RD)'),
)
role_id = django_filters.ModelMultipleChoiceFilter(
queryset=Role.objects.all(),
label='Role (ID)',
label=_('Role (ID)'),
)
role = django_filters.ModelMultipleChoiceFilter(
field_name='role__slug',
queryset=Role.objects.all(),
to_field_name='slug',
label='Role (slug)',
label=_('Role (slug)'),
)
status = django_filters.MultipleChoiceFilter(
choices=IPRangeStatusChoices,
@@ -468,87 +469,87 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
)
parent = MultiValueCharFilter(
method='search_by_parent',
label='Parent prefix',
label=_('Parent prefix'),
)
address = MultiValueCharFilter(
method='filter_address',
label='Address',
label=_('Address'),
)
mask_length = django_filters.NumberFilter(
method='filter_mask_length',
label='Mask length',
label=_('Mask length'),
)
vrf_id = django_filters.ModelMultipleChoiceFilter(
queryset=VRF.objects.all(),
label='VRF',
label=_('VRF'),
)
vrf = django_filters.ModelMultipleChoiceFilter(
field_name='vrf__rd',
queryset=VRF.objects.all(),
to_field_name='rd',
label='VRF (RD)',
label=_('VRF (RD)'),
)
present_in_vrf_id = django_filters.ModelChoiceFilter(
queryset=VRF.objects.all(),
method='filter_present_in_vrf',
label='VRF'
label=_('VRF')
)
present_in_vrf = django_filters.ModelChoiceFilter(
queryset=VRF.objects.all(),
method='filter_present_in_vrf',
to_field_name='rd',
label='VRF (RD)',
label=_('VRF (RD)'),
)
device = MultiValueCharFilter(
method='filter_device',
field_name='name',
label='Device (name)',
label=_('Device (name)'),
)
device_id = MultiValueNumberFilter(
method='filter_device',
field_name='pk',
label='Device (ID)',
label=_('Device (ID)'),
)
virtual_machine = MultiValueCharFilter(
method='filter_virtual_machine',
field_name='name',
label='Virtual machine (name)',
label=_('Virtual machine (name)'),
)
virtual_machine_id = MultiValueNumberFilter(
method='filter_virtual_machine',
field_name='pk',
label='Virtual machine (ID)',
label=_('Virtual machine (ID)'),
)
interface = django_filters.ModelMultipleChoiceFilter(
field_name='interface__name',
queryset=Interface.objects.all(),
to_field_name='name',
label='Interface (name)',
label=_('Interface (name)'),
)
interface_id = django_filters.ModelMultipleChoiceFilter(
field_name='interface',
queryset=Interface.objects.all(),
label='Interface (ID)',
label=_('Interface (ID)'),
)
vminterface = django_filters.ModelMultipleChoiceFilter(
field_name='vminterface__name',
queryset=VMInterface.objects.all(),
to_field_name='name',
label='VM interface (name)',
label=_('VM interface (name)'),
)
vminterface_id = django_filters.ModelMultipleChoiceFilter(
field_name='vminterface',
queryset=VMInterface.objects.all(),
label='VM interface (ID)',
label=_('VM interface (ID)'),
)
fhrpgroup_id = django_filters.ModelMultipleChoiceFilter(
field_name='fhrpgroup',
queryset=FHRPGroup.objects.all(),
label='FHRP group (ID)',
label=_('FHRP group (ID)'),
)
assigned_to_interface = django_filters.BooleanFilter(
method='_assigned_to_interface',
label='Is assigned to an interface',
label=_('Is assigned to an interface'),
)
status = django_filters.MultipleChoiceFilter(
choices=IPAddressStatusChoices,
@@ -688,27 +689,27 @@ class FHRPGroupAssignmentFilterSet(ChangeLoggedModelFilterSet):
interface_type = ContentTypeFilter()
group_id = django_filters.ModelMultipleChoiceFilter(
queryset=FHRPGroup.objects.all(),
label='Group (ID)',
label=_('Group (ID)'),
)
device = MultiValueCharFilter(
method='filter_device',
field_name='name',
label='Device (name)',
label=_('Device (name)'),
)
device_id = MultiValueNumberFilter(
method='filter_device',
field_name='pk',
label='Device (ID)',
label=_('Device (ID)'),
)
virtual_machine = MultiValueCharFilter(
method='filter_virtual_machine',
field_name='name',
label='Virtual machine (name)',
label=_('Virtual machine (name)'),
)
virtual_machine_id = MultiValueNumberFilter(
method='filter_virtual_machine',
field_name='pk',
label='Virtual machine (ID)',
label=_('Virtual machine (ID)'),
)
class Meta:
@@ -787,57 +788,57 @@ class VLANFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
queryset=Region.objects.all(),
field_name='site__region',
lookup_expr='in',
label='Region (ID)',
label=_('Region (ID)'),
)
region = TreeNodeMultipleChoiceFilter(
queryset=Region.objects.all(),
field_name='site__region',
lookup_expr='in',
to_field_name='slug',
label='Region (slug)',
label=_('Region (slug)'),
)
site_group_id = TreeNodeMultipleChoiceFilter(
queryset=SiteGroup.objects.all(),
field_name='site__group',
lookup_expr='in',
label='Site group (ID)',
label=_('Site group (ID)'),
)
site_group = TreeNodeMultipleChoiceFilter(
queryset=SiteGroup.objects.all(),
field_name='site__group',
lookup_expr='in',
to_field_name='slug',
label='Site group (slug)',
label=_('Site group (slug)'),
)
site_id = django_filters.ModelMultipleChoiceFilter(
queryset=Site.objects.all(),
label='Site (ID)',
label=_('Site (ID)'),
)
site = django_filters.ModelMultipleChoiceFilter(
field_name='site__slug',
queryset=Site.objects.all(),
to_field_name='slug',
label='Site (slug)',
label=_('Site (slug)'),
)
group_id = django_filters.ModelMultipleChoiceFilter(
queryset=VLANGroup.objects.all(),
label='Group (ID)',
label=_('Group (ID)'),
)
group = django_filters.ModelMultipleChoiceFilter(
field_name='group__slug',
queryset=VLANGroup.objects.all(),
to_field_name='slug',
label='Group',
label=_('Group'),
)
role_id = django_filters.ModelMultipleChoiceFilter(
queryset=Role.objects.all(),
label='Role (ID)',
label=_('Role (ID)'),
)
role = django_filters.ModelMultipleChoiceFilter(
field_name='role__slug',
queryset=Role.objects.all(),
to_field_name='slug',
label='Role (slug)',
label=_('Role (slug)'),
)
status = django_filters.MultipleChoiceFilter(
choices=VLANStatusChoices,
@@ -893,23 +894,23 @@ class ServiceTemplateFilterSet(NetBoxModelFilterSet):
class ServiceFilterSet(NetBoxModelFilterSet):
device_id = django_filters.ModelMultipleChoiceFilter(
queryset=Device.objects.all(),
label='Device (ID)',
label=_('Device (ID)'),
)
device = django_filters.ModelMultipleChoiceFilter(
field_name='device__name',
queryset=Device.objects.all(),
to_field_name='name',
label='Device (name)',
label=_('Device (name)'),
)
virtual_machine_id = django_filters.ModelMultipleChoiceFilter(
queryset=VirtualMachine.objects.all(),
label='Virtual machine (ID)',
label=_('Virtual machine (ID)'),
)
virtual_machine = django_filters.ModelMultipleChoiceFilter(
field_name='virtual_machine__name',
queryset=VirtualMachine.objects.all(),
to_field_name='name',
label='Virtual machine (name)',
label=_('Virtual machine (name)'),
)
port = NumericArrayFilter(
field_name='ports',
@@ -939,24 +940,24 @@ class L2VPNFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
import_target_id = django_filters.ModelMultipleChoiceFilter(
field_name='import_targets',
queryset=RouteTarget.objects.all(),
label='Import target',
label=_('Import target'),
)
import_target = django_filters.ModelMultipleChoiceFilter(
field_name='import_targets__name',
queryset=RouteTarget.objects.all(),
to_field_name='name',
label='Import target (name)',
label=_('Import target (name)'),
)
export_target_id = django_filters.ModelMultipleChoiceFilter(
field_name='export_targets',
queryset=RouteTarget.objects.all(),
label='Export target',
label=_('Export target'),
)
export_target = django_filters.ModelMultipleChoiceFilter(
field_name='export_targets__name',
queryset=RouteTarget.objects.all(),
to_field_name='name',
label='Export target (name)',
label=_('Export target (name)'),
)
class Meta:
@@ -977,92 +978,92 @@ class L2VPNFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
class L2VPNTerminationFilterSet(NetBoxModelFilterSet):
l2vpn_id = django_filters.ModelMultipleChoiceFilter(
queryset=L2VPN.objects.all(),
label='L2VPN (ID)',
label=_('L2VPN (ID)'),
)
l2vpn = django_filters.ModelMultipleChoiceFilter(
field_name='l2vpn__slug',
queryset=L2VPN.objects.all(),
to_field_name='slug',
label='L2VPN (slug)',
label=_('L2VPN (slug)'),
)
region = MultiValueCharFilter(
method='filter_region',
field_name='slug',
label='Region (slug)',
label=_('Region (slug)'),
)
region_id = MultiValueNumberFilter(
method='filter_region',
field_name='pk',
label='Region (ID)',
label=_('Region (ID)'),
)
site = MultiValueCharFilter(
method='filter_site',
field_name='slug',
label='Site (slug)',
label=_('Site (slug)'),
)
site_id = MultiValueNumberFilter(
method='filter_site',
field_name='pk',
label='Site (ID)',
label=_('Site (ID)'),
)
device = django_filters.ModelMultipleChoiceFilter(
field_name='interface__device__name',
queryset=Device.objects.all(),
to_field_name='name',
label='Device (name)',
label=_('Device (name)'),
)
device_id = django_filters.ModelMultipleChoiceFilter(
field_name='interface__device',
queryset=Device.objects.all(),
label='Device (ID)',
label=_('Device (ID)'),
)
virtual_machine = django_filters.ModelMultipleChoiceFilter(
field_name='vminterface__virtual_machine__name',
queryset=VirtualMachine.objects.all(),
to_field_name='name',
label='Virtual machine (name)',
label=_('Virtual machine (name)'),
)
virtual_machine_id = django_filters.ModelMultipleChoiceFilter(
field_name='vminterface__virtual_machine',
queryset=VirtualMachine.objects.all(),
label='Virtual machine (ID)',
label=_('Virtual machine (ID)'),
)
interface = django_filters.ModelMultipleChoiceFilter(
field_name='interface__name',
queryset=Interface.objects.all(),
to_field_name='name',
label='Interface (name)',
label=_('Interface (name)'),
)
interface_id = django_filters.ModelMultipleChoiceFilter(
field_name='interface',
queryset=Interface.objects.all(),
label='Interface (ID)',
label=_('Interface (ID)'),
)
vminterface = django_filters.ModelMultipleChoiceFilter(
field_name='vminterface__name',
queryset=VMInterface.objects.all(),
to_field_name='name',
label='VM interface (name)',
label=_('VM interface (name)'),
)
vminterface_id = django_filters.ModelMultipleChoiceFilter(
field_name='vminterface',
queryset=VMInterface.objects.all(),
label='VM Interface (ID)',
label=_('VM Interface (ID)'),
)
vlan = django_filters.ModelMultipleChoiceFilter(
field_name='vlan__name',
queryset=VLAN.objects.all(),
to_field_name='name',
label='VLAN (name)',
label=_('VLAN (name)'),
)
vlan_vid = django_filters.NumberFilter(
field_name='vlan__vid',
label='VLAN number (1-4094)',
label=_('VLAN number (1-4094)'),
)
vlan_id = django_filters.ModelMultipleChoiceFilter(
field_name='vlan',
queryset=VLAN.objects.all(),
label='VLAN (ID)',
label=_('VLAN (ID)'),
)
assigned_object_type = ContentTypeFilter()

View File

@@ -1,4 +1,5 @@
from django import forms
from django.utils.translation import gettext as _
from utilities.forms import BootstrapMixin, ExpandableIPAddressField
@@ -9,5 +10,5 @@ __all__ = (
class IPAddressBulkCreateForm(BootstrapMixin, forms.Form):
pattern = ExpandableIPAddressField(
label='Address pattern'
label=_('Address pattern')
)

View File

@@ -1,4 +1,5 @@
from django import forms
from django.utils.translation import gettext as _
from dcim.models import Region, Site, SiteGroup
from ipam.choices import *
@@ -40,7 +41,7 @@ class VRFBulkEditForm(NetBoxModelBulkEditForm):
enforce_unique = forms.NullBooleanField(
required=False,
widget=BulkEditNullBooleanSelect(),
label='Enforce unique space'
label=_('Enforce unique space')
)
description = forms.CharField(
max_length=200,
@@ -104,7 +105,7 @@ class ASNBulkEditForm(NetBoxModelBulkEditForm):
rir = DynamicModelChoiceField(
queryset=RIR.objects.all(),
required=False,
label='RIR'
label=_('RIR')
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
@@ -130,7 +131,7 @@ class AggregateBulkEditForm(NetBoxModelBulkEditForm):
rir = DynamicModelChoiceField(
queryset=RIR.objects.all(),
required=False,
label='RIR'
label=_('RIR')
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
@@ -191,7 +192,7 @@ class PrefixBulkEditForm(NetBoxModelBulkEditForm):
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
prefix_length = forms.IntegerField(
min_value=PREFIX_LENGTH_MIN,
@@ -214,12 +215,12 @@ class PrefixBulkEditForm(NetBoxModelBulkEditForm):
is_pool = forms.NullBooleanField(
required=False,
widget=BulkEditNullBooleanSelect(),
label='Is a pool'
label=_('Is a pool')
)
mark_utilized = forms.NullBooleanField(
required=False,
widget=BulkEditNullBooleanSelect(),
label='Treat as 100% utilized'
label=_('Treat as 100% utilized')
)
description = forms.CharField(
max_length=200,
@@ -245,7 +246,7 @@ class IPRangeBulkEditForm(NetBoxModelBulkEditForm):
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
tenant = DynamicModelChoiceField(
queryset=Tenant.objects.all(),
@@ -282,7 +283,7 @@ class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
mask_length = forms.IntegerField(
min_value=IPADDRESS_MASK_LENGTH_MIN,
@@ -306,7 +307,7 @@ class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
dns_name = forms.CharField(
max_length=255,
required=False,
label='DNS name'
label=_('DNS name')
)
description = forms.CharField(
max_length=200,
@@ -336,18 +337,18 @@ class FHRPGroupBulkEditForm(NetBoxModelBulkEditForm):
group_id = forms.IntegerField(
min_value=0,
required=False,
label='Group ID'
label=_('Group ID')
)
auth_type = forms.ChoiceField(
choices=add_blank_choice(FHRPGroupAuthTypeChoices),
required=False,
widget=StaticSelect(),
label='Authentication type'
label=_('Authentication type')
)
auth_key = forms.CharField(
max_length=255,
required=False,
label='Authentication key'
label=_('Authentication key')
)
name = forms.CharField(
max_length=100,
@@ -379,13 +380,13 @@ class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
min_value=VLAN_VID_MIN,
max_value=VLAN_VID_MAX,
required=False,
label='Minimum child VLAN VID'
label=_('Minimum child VLAN VID')
)
max_vid = forms.IntegerField(
min_value=VLAN_VID_MIN,
max_value=VLAN_VID_MAX,
required=False,
label='Maximum child VLAN VID'
label=_('Maximum child VLAN VID')
)
description = forms.CharField(
max_length=200,

View File

@@ -1,6 +1,7 @@
from django import forms
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _
from dcim.models import Device, Interface, Site
from ipam.choices import *
@@ -36,7 +37,7 @@ class VRFCSVForm(NetBoxModelCSVForm):
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
class Meta:
@@ -49,7 +50,7 @@ class RouteTargetCSVForm(NetBoxModelCSVForm):
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
class Meta:
@@ -64,7 +65,7 @@ class RIRCSVForm(NetBoxModelCSVForm):
model = RIR
fields = ('name', 'slug', 'is_private', 'description', 'tags')
help_texts = {
'name': 'RIR name',
'name': _('RIR name'),
}
@@ -72,13 +73,13 @@ class AggregateCSVForm(NetBoxModelCSVForm):
rir = CSVModelChoiceField(
queryset=RIR.objects.all(),
to_field_name='name',
help_text='Assigned RIR'
help_text=_('Assigned RIR')
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
class Meta:
@@ -90,13 +91,13 @@ class ASNCSVForm(NetBoxModelCSVForm):
rir = CSVModelChoiceField(
queryset=RIR.objects.all(),
to_field_name='name',
help_text='Assigned RIR'
help_text=_('Assigned RIR')
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
class Meta:
@@ -117,41 +118,41 @@ class PrefixCSVForm(NetBoxModelCSVForm):
queryset=VRF.objects.all(),
to_field_name='name',
required=False,
help_text='Assigned VRF'
help_text=_('Assigned VRF')
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
site = CSVModelChoiceField(
queryset=Site.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned site'
help_text=_('Assigned site')
)
vlan_group = CSVModelChoiceField(
queryset=VLANGroup.objects.all(),
required=False,
to_field_name='name',
help_text="VLAN's group (if any)"
help_text=_("VLAN's group (if any)")
)
vlan = CSVModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
to_field_name='vid',
help_text="Assigned VLAN"
help_text=_("Assigned VLAN")
)
status = CSVChoiceField(
choices=PrefixStatusChoices,
help_text='Operational status'
help_text=_('Operational status')
)
role = CSVModelChoiceField(
queryset=Role.objects.all(),
required=False,
to_field_name='name',
help_text='Functional role'
help_text=_('Functional role')
)
class Meta:
@@ -181,23 +182,23 @@ class IPRangeCSVForm(NetBoxModelCSVForm):
queryset=VRF.objects.all(),
to_field_name='name',
required=False,
help_text='Assigned VRF'
help_text=_('Assigned VRF')
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
status = CSVChoiceField(
choices=IPRangeStatusChoices,
help_text='Operational status'
help_text=_('Operational status')
)
role = CSVModelChoiceField(
queryset=Role.objects.all(),
required=False,
to_field_name='name',
help_text='Functional role'
help_text=_('Functional role')
)
class Meta:
@@ -212,43 +213,43 @@ class IPAddressCSVForm(NetBoxModelCSVForm):
queryset=VRF.objects.all(),
to_field_name='name',
required=False,
help_text='Assigned VRF'
help_text=_('Assigned VRF')
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
to_field_name='name',
required=False,
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
status = CSVChoiceField(
choices=IPAddressStatusChoices,
help_text='Operational status'
help_text=_('Operational status')
)
role = CSVChoiceField(
choices=IPAddressRoleChoices,
required=False,
help_text='Functional role'
help_text=_('Functional role')
)
device = CSVModelChoiceField(
queryset=Device.objects.all(),
required=False,
to_field_name='name',
help_text='Parent device of assigned interface (if any)'
help_text=_('Parent device of assigned interface (if any)')
)
virtual_machine = CSVModelChoiceField(
queryset=VirtualMachine.objects.all(),
required=False,
to_field_name='name',
help_text='Parent VM of assigned interface (if any)'
help_text=_('Parent VM of assigned interface (if any)')
)
interface = CSVModelChoiceField(
queryset=Interface.objects.none(), # Can also refer to VMInterface
required=False,
to_field_name='name',
help_text='Assigned interface'
help_text=_('Assigned interface')
)
is_primary = forms.BooleanField(
help_text='Make this the primary IP for the assigned device',
help_text=_('Make this the primary IP for the assigned device'),
required=False
)
@@ -333,7 +334,7 @@ class VLANGroupCSVForm(NetBoxModelCSVForm):
scope_type = CSVContentTypeField(
queryset=ContentType.objects.filter(model__in=VLANGROUP_SCOPE_TYPES),
required=False,
label='Scope type (app & model)'
label=_('Scope type (app & model)')
)
min_vid = forms.IntegerField(
min_value=VLAN_VID_MIN,
@@ -361,29 +362,29 @@ class VLANCSVForm(NetBoxModelCSVForm):
queryset=Site.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned site'
help_text=_('Assigned site')
)
group = CSVModelChoiceField(
queryset=VLANGroup.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned VLAN group'
help_text=_('Assigned VLAN group')
)
tenant = CSVModelChoiceField(
queryset=Tenant.objects.all(),
to_field_name='name',
required=False,
help_text='Assigned tenant'
help_text=_('Assigned tenant')
)
status = CSVChoiceField(
choices=VLANStatusChoices,
help_text='Operational status'
help_text=_('Operational status')
)
role = CSVModelChoiceField(
queryset=Role.objects.all(),
required=False,
to_field_name='name',
help_text='Functional role'
help_text=_('Functional role')
)
class Meta:
@@ -398,7 +399,7 @@ class VLANCSVForm(NetBoxModelCSVForm):
class ServiceTemplateCSVForm(NetBoxModelCSVForm):
protocol = CSVChoiceField(
choices=ServiceProtocolChoices,
help_text='IP protocol'
help_text=_('IP protocol')
)
class Meta:
@@ -411,17 +412,17 @@ class ServiceCSVForm(NetBoxModelCSVForm):
queryset=Device.objects.all(),
required=False,
to_field_name='name',
help_text='Required if not assigned to a VM'
help_text=_('Required if not assigned to a VM')
)
virtual_machine = CSVModelChoiceField(
queryset=VirtualMachine.objects.all(),
required=False,
to_field_name='name',
help_text='Required if not assigned to a device'
help_text=_('Required if not assigned to a device')
)
protocol = CSVChoiceField(
choices=ServiceProtocolChoices,
help_text='IP protocol'
help_text=_('IP protocol')
)
class Meta:
@@ -437,7 +438,7 @@ class L2VPNCSVForm(NetBoxModelCSVForm):
)
type = CSVChoiceField(
choices=L2VPNTypeChoices,
help_text='L2VPN type'
help_text=_('L2VPN type')
)
class Meta:
@@ -450,31 +451,31 @@ class L2VPNTerminationCSVForm(NetBoxModelCSVForm):
queryset=L2VPN.objects.all(),
required=True,
to_field_name='name',
label='L2VPN',
label=_('L2VPN'),
)
device = CSVModelChoiceField(
queryset=Device.objects.all(),
required=False,
to_field_name='name',
help_text='Parent device (for interface)'
help_text=_('Parent device (for interface)')
)
virtual_machine = CSVModelChoiceField(
queryset=VirtualMachine.objects.all(),
required=False,
to_field_name='name',
help_text='Parent virtual machine (for interface)'
help_text=_('Parent virtual machine (for interface)')
)
interface = CSVModelChoiceField(
queryset=Interface.objects.none(), # Can also refer to VMInterface
required=False,
to_field_name='name',
help_text='Assigned interface (device or VM)'
help_text=_('Assigned interface (device or VM)')
)
vlan = CSVModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
to_field_name='name',
help_text='Assigned VLAN'
help_text=_('Assigned VLAN')
)
class Meta:

View File

@@ -397,13 +397,13 @@ class VLANGroupFilterForm(NetBoxModelFilterSetForm):
required=False,
min_value=VLAN_VID_MIN,
max_value=VLAN_VID_MAX,
label='Minimum VID'
label=_('Minimum VID')
)
max_vid = forms.IntegerField(
required=False,
min_value=VLAN_VID_MIN,
max_value=VLAN_VID_MAX,
label='Maximum VID'
label=_('Maximum VID')
)
tag = TagFilterField(model)

View File

@@ -1,6 +1,7 @@
from django import forms
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _
from dcim.models import Device, Interface, Location, Rack, Region, Site, SiteGroup
from ipam.choices import *
@@ -67,7 +68,7 @@ class VRFForm(TenancyForm, NetBoxModelForm):
'rd': "RD",
}
help_texts = {
'rd': "Route distinguisher in any format",
'rd': _("Route distinguisher in any format"),
}
@@ -104,7 +105,7 @@ class RIRForm(NetBoxModelForm):
class AggregateForm(TenancyForm, NetBoxModelForm):
rir = DynamicModelChoiceField(
queryset=RIR.objects.all(),
label='RIR'
label=_('RIR')
)
comments = CommentField()
@@ -119,8 +120,8 @@ class AggregateForm(TenancyForm, NetBoxModelForm):
'prefix', 'rir', 'date_added', 'tenant_group', 'tenant', 'description', 'comments', 'tags',
]
help_texts = {
'prefix': "IPv4 or IPv6 network",
'rir': "Regional Internet Registry responsible for this prefix",
'prefix': _("IPv4 or IPv6 network"),
'rir': _("Regional Internet Registry responsible for this prefix"),
}
widgets = {
'date_added': DatePicker(),
@@ -130,11 +131,11 @@ class AggregateForm(TenancyForm, NetBoxModelForm):
class ASNForm(TenancyForm, NetBoxModelForm):
rir = DynamicModelChoiceField(
queryset=RIR.objects.all(),
label='RIR',
label=_('RIR'),
)
sites = DynamicModelMultipleChoiceField(
queryset=Site.objects.all(),
label='Sites',
label=_('Sites'),
required=False
)
comments = CommentField()
@@ -150,8 +151,8 @@ class ASNForm(TenancyForm, NetBoxModelForm):
'asn', 'rir', 'sites', 'tenant_group', 'tenant', 'description', 'comments', 'tags'
]
help_texts = {
'asn': "AS number",
'rir': "Regional Internet Registry responsible for this prefix",
'asn': _("AS number"),
'rir': _("Regional Internet Registry responsible for this prefix"),
}
widgets = {
'date_added': DatePicker(),
@@ -189,7 +190,7 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
region = DynamicModelChoiceField(
queryset=Region.objects.all(),
@@ -217,7 +218,7 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
vlan_group = DynamicModelChoiceField(
queryset=VLANGroup.objects.all(),
required=False,
label='VLAN group',
label=_('VLAN group'),
null_option='None',
query_params={
'site': '$site'
@@ -229,7 +230,7 @@ class PrefixForm(TenancyForm, NetBoxModelForm):
vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
label='VLAN',
label=_('VLAN'),
query_params={
'site_id': '$site',
'group_id': '$vlan_group',
@@ -262,7 +263,7 @@ class IPRangeForm(TenancyForm, NetBoxModelForm):
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
role = DynamicModelChoiceField(
queryset=Role.objects.all(),
@@ -311,7 +312,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
vminterface = DynamicModelChoiceField(
queryset=VMInterface.objects.all(),
required=False,
label='Interface',
label=_('Interface'),
query_params={
'virtual_machine_id': '$virtual_machine'
}
@@ -319,17 +320,17 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
fhrpgroup = DynamicModelChoiceField(
queryset=FHRPGroup.objects.all(),
required=False,
label='FHRP Group'
label=_('FHRP Group')
)
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
nat_region = DynamicModelChoiceField(
queryset=Region.objects.all(),
required=False,
label='Region',
label=_('Region'),
initial_params={
'sites': '$nat_site'
}
@@ -337,7 +338,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
nat_site_group = DynamicModelChoiceField(
queryset=SiteGroup.objects.all(),
required=False,
label='Site group',
label=_('Site group'),
initial_params={
'sites': '$nat_site'
}
@@ -345,7 +346,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
nat_site = DynamicModelChoiceField(
queryset=Site.objects.all(),
required=False,
label='Site',
label=_('Site'),
query_params={
'region_id': '$nat_region',
'group_id': '$nat_site_group',
@@ -354,7 +355,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
nat_rack = DynamicModelChoiceField(
queryset=Rack.objects.all(),
required=False,
label='Rack',
label=_('Rack'),
null_option='None',
query_params={
'site_id': '$site'
@@ -363,7 +364,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
nat_device = DynamicModelChoiceField(
queryset=Device.objects.all(),
required=False,
label='Device',
label=_('Device'),
query_params={
'site_id': '$site',
'rack_id': '$nat_rack',
@@ -372,12 +373,12 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
nat_cluster = DynamicModelChoiceField(
queryset=Cluster.objects.all(),
required=False,
label='Cluster'
label=_('Cluster')
)
nat_virtual_machine = DynamicModelChoiceField(
queryset=VirtualMachine.objects.all(),
required=False,
label='Virtual Machine',
label=_('Virtual Machine'),
query_params={
'cluster_id': '$nat_cluster',
}
@@ -385,12 +386,12 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
nat_vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
nat_inside = DynamicModelChoiceField(
queryset=IPAddress.objects.all(),
required=False,
label='IP Address',
label=_('IP Address'),
query_params={
'device_id': '$nat_device',
'virtual_machine_id': '$nat_virtual_machine',
@@ -399,7 +400,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
)
primary_for_parent = forms.BooleanField(
required=False,
label='Make this the primary IP for the device/VM'
label=_('Make this the primary IP for the device/VM')
)
comments = CommentField()
@@ -500,7 +501,7 @@ class IPAddressBulkAddForm(TenancyForm, NetBoxModelForm):
vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
class Meta:
@@ -518,11 +519,11 @@ class IPAddressAssignForm(BootstrapMixin, forms.Form):
vrf_id = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
q = forms.CharField(
required=False,
label='Search',
label=_('Search'),
)
@@ -532,16 +533,16 @@ class FHRPGroupForm(NetBoxModelForm):
ip_vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(),
required=False,
label='VRF'
label=_('VRF')
)
ip_address = IPNetworkFormField(
required=False,
label='Address'
label=_('Address')
)
ip_status = forms.ChoiceField(
choices=add_blank_choice(IPAddressStatusChoices),
required=False,
label='Status'
label=_('Status')
)
comments = CommentField()
@@ -633,7 +634,7 @@ class VLANGroupForm(NetBoxModelForm):
initial_params={
'sites': '$site'
},
label='Site group'
label=_('Site group')
)
site = DynamicModelChoiceField(
queryset=Site.objects.all(),
@@ -670,7 +671,7 @@ class VLANGroupForm(NetBoxModelForm):
initial_params={
'clusters': '$cluster'
},
label='Cluster group'
label=_('Cluster group')
)
cluster = DynamicModelChoiceField(
queryset=Cluster.objects.all(),
@@ -734,7 +735,7 @@ class VLANForm(TenancyForm, NetBoxModelForm):
),
required=False,
widget=StaticSelect,
label='Group scope'
label=_('Group scope')
)
group = DynamicModelChoiceField(
queryset=VLANGroup.objects.all(),
@@ -742,7 +743,7 @@ class VLANForm(TenancyForm, NetBoxModelForm):
query_params={
'scope_type': '$scope_type',
},
label='VLAN Group'
label=_('VLAN Group')
)
# Site assignment fields
@@ -752,7 +753,7 @@ class VLANForm(TenancyForm, NetBoxModelForm):
initial_params={
'sites': '$site'
},
label='Region'
label=_('Region')
)
sitegroup = DynamicModelChoiceField(
queryset=SiteGroup.objects.all(),
@@ -760,7 +761,7 @@ class VLANForm(TenancyForm, NetBoxModelForm):
initial_params={
'sites': '$site'
},
label='Site group'
label=_('Site group')
)
site = DynamicModelChoiceField(
queryset=Site.objects.all(),
@@ -786,12 +787,12 @@ class VLANForm(TenancyForm, NetBoxModelForm):
'tags',
]
help_texts = {
'site': "Leave blank if this VLAN spans multiple sites",
'group': "VLAN group (optional)",
'vid': "Configured VLAN ID",
'name': "Configured VLAN name",
'status': "Operational status of this VLAN",
'role': "The primary function of this VLAN",
'site': _("Leave blank if this VLAN spans multiple sites"),
'group': _("VLAN group (optional)"),
'vid': _("Configured VLAN ID"),
'name': _("Configured VLAN name"),
'status': _("Operational status of this VLAN"),
'role': _("The primary function of this VLAN"),
}
widgets = {
'status': StaticSelect(),
@@ -804,7 +805,7 @@ class ServiceTemplateForm(NetBoxModelForm):
min_value=SERVICE_PORT_MIN,
max_value=SERVICE_PORT_MAX
),
help_text="Comma-separated list of one or more port numbers. A range may be specified using a hyphen."
help_text=_("Comma-separated list of one or more port numbers. A range may be specified using a hyphen.")
)
comments = CommentField()
@@ -836,12 +837,12 @@ class ServiceForm(NetBoxModelForm):
min_value=SERVICE_PORT_MIN,
max_value=SERVICE_PORT_MAX
),
help_text="Comma-separated list of one or more port numbers. A range may be specified using a hyphen."
help_text=_("Comma-separated list of one or more port numbers. A range may be specified using a hyphen.")
)
ipaddresses = DynamicModelMultipleChoiceField(
queryset=IPAddress.objects.all(),
required=False,
label='IP Addresses',
label=_('IP Addresses'),
query_params={
'device_id': '$device',
'virtual_machine_id': '$virtual_machine',
@@ -855,8 +856,8 @@ class ServiceForm(NetBoxModelForm):
'device', 'virtual_machine', 'name', 'protocol', 'ports', 'ipaddresses', 'description', 'comments', 'tags',
]
help_texts = {
'ipaddresses': "IP address assignment is optional. If no IPs are selected, the service is assumed to be "
"reachable via all IPs assigned to the device.",
'ipaddresses': _("IP address assignment is optional. If no IPs are selected, the service is assumed to be "
"reachable via all IPs assigned to the device."),
}
widgets = {
'protocol': StaticSelect(),
@@ -937,12 +938,12 @@ class L2VPNTerminationForm(NetBoxModelForm):
queryset=L2VPN.objects.all(),
required=True,
query_params={},
label='L2VPN',
label=_('L2VPN'),
fetch_trigger='open'
)
device_vlan = DynamicModelChoiceField(
queryset=Device.objects.all(),
label="Available on Device",
label=_("Available on Device"),
required=False,
query_params={}
)
@@ -952,7 +953,7 @@ class L2VPNTerminationForm(NetBoxModelForm):
query_params={
'available_on_device': '$device_vlan'
},
label='VLAN'
label=_('VLAN')
)
device = DynamicModelChoiceField(
queryset=Device.objects.all(),
@@ -977,7 +978,7 @@ class L2VPNTerminationForm(NetBoxModelForm):
query_params={
'virtual_machine_id': '$virtual_machine'
},
label='Interface'
label=_('Interface')
)
class Meta:

View File

@@ -6,6 +6,7 @@ from django.db import models
from django.db.models import F
from django.urls import reverse
from django.utils.functional import cached_property
from django.utils.translation import gettext as _
from dcim.fields import ASNField
from dcim.models import Device
@@ -64,7 +65,7 @@ class RIR(OrganizationalModel):
is_private = models.BooleanField(
default=False,
verbose_name='Private',
help_text='IP space managed by this RIR is considered private'
help_text=_('IP space managed by this RIR is considered private')
)
class Meta:
@@ -84,7 +85,7 @@ class ASN(PrimaryModel):
asn = ASNField(
unique=True,
verbose_name='ASN',
help_text='32-bit autonomous system number'
help_text=_('32-bit autonomous system number')
)
rir = models.ForeignKey(
to='ipam.RIR',
@@ -263,7 +264,7 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
assigned to a VLAN where appropriate.
"""
prefix = IPNetworkField(
help_text='IPv4 or IPv6 network with mask'
help_text=_('IPv4 or IPv6 network with mask')
)
site = models.ForeignKey(
to='dcim.Site',
@@ -300,7 +301,7 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
choices=PrefixStatusChoices,
default=PrefixStatusChoices.STATUS_ACTIVE,
verbose_name='Status',
help_text='Operational status of this prefix'
help_text=_('Operational status of this prefix')
)
role = models.ForeignKey(
to='ipam.Role',
@@ -308,16 +309,16 @@ class Prefix(GetAvailablePrefixesMixin, PrimaryModel):
related_name='prefixes',
blank=True,
null=True,
help_text='The primary function of this prefix'
help_text=_('The primary function of this prefix')
)
is_pool = models.BooleanField(
verbose_name='Is a pool',
default=False,
help_text='All IP addresses within this prefix are considered usable'
help_text=_('All IP addresses within this prefix are considered usable')
)
mark_utilized = models.BooleanField(
default=False,
help_text="Treat as 100% utilized"
help_text=_("Treat as 100% utilized")
)
# Cached depth & child counts
@@ -538,10 +539,10 @@ class IPRange(PrimaryModel):
A range of IP addresses, defined by start and end addresses.
"""
start_address = IPAddressField(
help_text='IPv4 or IPv6 address (with mask)'
help_text=_('IPv4 or IPv6 address (with mask)')
)
end_address = IPAddressField(
help_text='IPv4 or IPv6 address (with mask)'
help_text=_('IPv4 or IPv6 address (with mask)')
)
size = models.PositiveIntegerField(
editable=False
@@ -565,7 +566,7 @@ class IPRange(PrimaryModel):
max_length=50,
choices=IPRangeStatusChoices,
default=IPRangeStatusChoices.STATUS_ACTIVE,
help_text='Operational status of this range'
help_text=_('Operational status of this range')
)
role = models.ForeignKey(
to='ipam.Role',
@@ -573,7 +574,7 @@ class IPRange(PrimaryModel):
related_name='ip_ranges',
blank=True,
null=True,
help_text='The primary function of this range'
help_text=_('The primary function of this range')
)
clone_fields = (
@@ -736,7 +737,7 @@ class IPAddress(PrimaryModel):
which has a NAT outside IP, that Interface's Device can use either the inside or outside IP as its primary IP.
"""
address = IPAddressField(
help_text='IPv4 or IPv6 address (with mask)'
help_text=_('IPv4 or IPv6 address (with mask)')
)
vrf = models.ForeignKey(
to='ipam.VRF',
@@ -757,13 +758,13 @@ class IPAddress(PrimaryModel):
max_length=50,
choices=IPAddressStatusChoices,
default=IPAddressStatusChoices.STATUS_ACTIVE,
help_text='The operational status of this IP'
help_text=_('The operational status of this IP')
)
role = models.CharField(
max_length=50,
choices=IPAddressRoleChoices,
blank=True,
help_text='The functional role of this IP'
help_text=_('The functional role of this IP')
)
assigned_object_type = models.ForeignKey(
to=ContentType,
@@ -788,14 +789,14 @@ class IPAddress(PrimaryModel):
blank=True,
null=True,
verbose_name='NAT (Inside)',
help_text='The IP for which this address is the "outside" IP'
help_text=_('The IP for which this address is the "outside" IP')
)
dns_name = models.CharField(
max_length=255,
blank=True,
validators=[DNSValidator],
verbose_name='DNS Name',
help_text='Hostname or FQDN (not case-sensitive)'
help_text=_('Hostname or FQDN (not case-sensitive)')
)
objects = IPAddressManager()

View File

@@ -4,6 +4,7 @@ from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext as _
from dcim.models import Interface
from ipam.choices import *
@@ -50,7 +51,7 @@ class VLANGroup(OrganizationalModel):
MinValueValidator(VLAN_VID_MIN),
MaxValueValidator(VLAN_VID_MAX)
),
help_text='Lowest permissible ID of a child VLAN'
help_text=_('Lowest permissible ID of a child VLAN')
)
max_vid = models.PositiveSmallIntegerField(
verbose_name='Maximum VLAN ID',
@@ -59,7 +60,7 @@ class VLANGroup(OrganizationalModel):
MinValueValidator(VLAN_VID_MIN),
MaxValueValidator(VLAN_VID_MAX)
),
help_text='Highest permissible ID of a child VLAN'
help_text=_('Highest permissible ID of a child VLAN')
)
class Meta:

View File

@@ -1,5 +1,6 @@
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext as _
from ipam.constants import *
from netbox.models import PrimaryModel
@@ -26,7 +27,7 @@ class VRF(PrimaryModel):
blank=True,
null=True,
verbose_name='Route distinguisher',
help_text='Unique route distinguisher (as defined in RFC 4364)'
help_text=_('Unique route distinguisher (as defined in RFC 4364)')
)
tenant = models.ForeignKey(
to='tenancy.Tenant',
@@ -38,7 +39,7 @@ class VRF(PrimaryModel):
enforce_unique = models.BooleanField(
default=True,
verbose_name='Enforce unique space',
help_text='Prevent duplicate prefixes/IP addresses within this VRF'
help_text=_('Prevent duplicate prefixes/IP addresses within this VRF')
)
import_targets = models.ManyToManyField(
to='ipam.RouteTarget',
@@ -76,7 +77,7 @@ class RouteTarget(PrimaryModel):
name = models.CharField(
max_length=VRF_RD_MAX_LENGTH, # Same format options as VRF RD (RFC 4360 section 4)
unique=True,
help_text='Route target value (formatted in accordance with RFC 4360)'
help_text=_('Route target value (formatted in accordance with RFC 4360)')
)
tenant = models.ForeignKey(
to='tenancy.Tenant',