mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
10300 initial translation support use gettext
This commit is contained in:
@@ -3,6 +3,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext as _
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
|
||||
from dcim.choices import *
|
||||
@@ -52,7 +53,7 @@ class ComponentTemplateModel(WebhooksMixin, ChangeLoggedModel):
|
||||
label = models.CharField(
|
||||
max_length=64,
|
||||
blank=True,
|
||||
help_text="Physical label"
|
||||
help_text=_("Physical label")
|
||||
)
|
||||
description = models.CharField(
|
||||
max_length=200,
|
||||
@@ -222,13 +223,13 @@ class PowerPortTemplate(ModularComponentTemplateModel):
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Maximum power draw (watts)"
|
||||
help_text=_("Maximum power draw (watts)")
|
||||
)
|
||||
allocated_draw = models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Allocated power draw (watts)"
|
||||
help_text=_("Allocated power draw (watts)")
|
||||
)
|
||||
|
||||
component_model = PowerPort
|
||||
@@ -283,7 +284,7 @@ class PowerOutletTemplate(ModularComponentTemplateModel):
|
||||
max_length=50,
|
||||
choices=PowerOutletFeedLegChoices,
|
||||
blank=True,
|
||||
help_text="Phase (for three-phase feeds)"
|
||||
help_text=_("Phase (for three-phase feeds)")
|
||||
)
|
||||
|
||||
component_model = PowerOutlet
|
||||
@@ -526,7 +527,7 @@ class ModuleBayTemplate(ComponentTemplateModel):
|
||||
position = models.CharField(
|
||||
max_length=30,
|
||||
blank=True,
|
||||
help_text='Identifier to reference when renaming installed components'
|
||||
help_text=_('Identifier to reference when renaming installed components')
|
||||
)
|
||||
|
||||
component_model = ModuleBay
|
||||
@@ -621,7 +622,7 @@ class InventoryItemTemplate(MPTTModel, ComponentTemplateModel):
|
||||
max_length=50,
|
||||
verbose_name='Part ID',
|
||||
blank=True,
|
||||
help_text='Manufacturer-assigned part identifier'
|
||||
help_text=_('Manufacturer-assigned part identifier')
|
||||
)
|
||||
|
||||
objects = TreeManager()
|
||||
|
@@ -7,6 +7,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.db import models
|
||||
from django.db.models import Sum
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext as _
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
|
||||
from dcim.choices import *
|
||||
@@ -60,7 +61,7 @@ class ComponentModel(NetBoxModel):
|
||||
label = models.CharField(
|
||||
max_length=64,
|
||||
blank=True,
|
||||
help_text="Physical label"
|
||||
help_text=_("Physical label")
|
||||
)
|
||||
description = models.CharField(
|
||||
max_length=200,
|
||||
@@ -129,7 +130,7 @@ class CabledObjectModel(models.Model):
|
||||
)
|
||||
mark_connected = models.BooleanField(
|
||||
default=False,
|
||||
help_text="Treat as if a cable is connected"
|
||||
help_text=_("Treat as if a cable is connected")
|
||||
)
|
||||
|
||||
cable_terminations = GenericRelation(
|
||||
@@ -261,13 +262,13 @@ class ConsolePort(ModularComponentModel, CabledObjectModel, PathEndpoint):
|
||||
max_length=50,
|
||||
choices=ConsolePortTypeChoices,
|
||||
blank=True,
|
||||
help_text='Physical port type'
|
||||
help_text=_('Physical port type')
|
||||
)
|
||||
speed = models.PositiveIntegerField(
|
||||
choices=ConsolePortSpeedChoices,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='Port speed in bits per second'
|
||||
help_text=_('Port speed in bits per second')
|
||||
)
|
||||
|
||||
clone_fields = ('device', 'module', 'type', 'speed')
|
||||
@@ -284,13 +285,13 @@ class ConsoleServerPort(ModularComponentModel, CabledObjectModel, PathEndpoint):
|
||||
max_length=50,
|
||||
choices=ConsolePortTypeChoices,
|
||||
blank=True,
|
||||
help_text='Physical port type'
|
||||
help_text=_('Physical port type')
|
||||
)
|
||||
speed = models.PositiveIntegerField(
|
||||
choices=ConsolePortSpeedChoices,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='Port speed in bits per second'
|
||||
help_text=_('Port speed in bits per second')
|
||||
)
|
||||
|
||||
clone_fields = ('device', 'module', 'type', 'speed')
|
||||
@@ -311,19 +312,19 @@ class PowerPort(ModularComponentModel, CabledObjectModel, PathEndpoint):
|
||||
max_length=50,
|
||||
choices=PowerPortTypeChoices,
|
||||
blank=True,
|
||||
help_text='Physical port type'
|
||||
help_text=_('Physical port type')
|
||||
)
|
||||
maximum_draw = models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Maximum power draw (watts)"
|
||||
help_text=_("Maximum power draw (watts)")
|
||||
)
|
||||
allocated_draw = models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Allocated power draw (watts)"
|
||||
help_text=_("Allocated power draw (watts)")
|
||||
)
|
||||
|
||||
clone_fields = ('device', 'module', 'maximum_draw', 'allocated_draw')
|
||||
@@ -420,7 +421,7 @@ class PowerOutlet(ModularComponentModel, CabledObjectModel, PathEndpoint):
|
||||
max_length=50,
|
||||
choices=PowerOutletTypeChoices,
|
||||
blank=True,
|
||||
help_text='Physical port type'
|
||||
help_text=_('Physical port type')
|
||||
)
|
||||
power_port = models.ForeignKey(
|
||||
to='dcim.PowerPort',
|
||||
@@ -433,7 +434,7 @@ class PowerOutlet(ModularComponentModel, CabledObjectModel, PathEndpoint):
|
||||
max_length=50,
|
||||
choices=PowerOutletFeedLegChoices,
|
||||
blank=True,
|
||||
help_text="Phase (for three-phase feeds)"
|
||||
help_text=_("Phase (for three-phase feeds)")
|
||||
)
|
||||
|
||||
clone_fields = ('device', 'module', 'type', 'power_port', 'feed_leg')
|
||||
@@ -550,7 +551,7 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
|
||||
mgmt_only = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name='Management only',
|
||||
help_text='This interface is used only for out-of-band management'
|
||||
help_text=_('This interface is used only for out-of-band management')
|
||||
)
|
||||
speed = models.PositiveIntegerField(
|
||||
blank=True,
|
||||
@@ -567,7 +568,7 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='WWN',
|
||||
help_text='64-bit World Wide Name'
|
||||
help_text=_('64-bit World Wide Name')
|
||||
)
|
||||
rf_role = models.CharField(
|
||||
max_length=30,
|
||||
@@ -970,7 +971,7 @@ class ModuleBay(ComponentModel):
|
||||
position = models.CharField(
|
||||
max_length=30,
|
||||
blank=True,
|
||||
help_text='Identifier to reference when renaming installed components'
|
||||
help_text=_('Identifier to reference when renaming installed components')
|
||||
)
|
||||
|
||||
clone_fields = ('device',)
|
||||
@@ -1084,7 +1085,7 @@ class InventoryItem(MPTTModel, ComponentModel):
|
||||
max_length=50,
|
||||
verbose_name='Part ID',
|
||||
blank=True,
|
||||
help_text='Manufacturer-assigned part identifier'
|
||||
help_text=_('Manufacturer-assigned part identifier')
|
||||
)
|
||||
serial = models.CharField(
|
||||
max_length=50,
|
||||
@@ -1097,11 +1098,11 @@ class InventoryItem(MPTTModel, ComponentModel):
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name='Asset tag',
|
||||
help_text='A unique tag used to identify this item'
|
||||
help_text=_('A unique tag used to identify this item')
|
||||
)
|
||||
discovered = models.BooleanField(
|
||||
default=False,
|
||||
help_text='This item was automatically discovered'
|
||||
help_text=_('This item was automatically discovered')
|
||||
)
|
||||
|
||||
objects = TreeManager()
|
||||
|
@@ -12,6 +12,7 @@ from django.db.models import F, ProtectedError
|
||||
from django.db.models.functions import Lower
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
@@ -84,7 +85,7 @@ class DeviceType(PrimaryModel, WeightMixin):
|
||||
part_number = models.CharField(
|
||||
max_length=50,
|
||||
blank=True,
|
||||
help_text='Discrete part number (optional)'
|
||||
help_text=_('Discrete part number (optional)')
|
||||
)
|
||||
u_height = models.DecimalField(
|
||||
max_digits=4,
|
||||
@@ -95,15 +96,15 @@ class DeviceType(PrimaryModel, WeightMixin):
|
||||
is_full_depth = models.BooleanField(
|
||||
default=True,
|
||||
verbose_name='Is full depth',
|
||||
help_text='Device consumes both front and rear rack faces'
|
||||
help_text=_('Device consumes both front and rear rack faces')
|
||||
)
|
||||
subdevice_role = models.CharField(
|
||||
max_length=50,
|
||||
choices=SubdeviceRoleChoices,
|
||||
blank=True,
|
||||
verbose_name='Parent/child status',
|
||||
help_text='Parent devices house child devices in device bays. Leave blank '
|
||||
'if this device type is neither a parent nor a child.'
|
||||
help_text=_('Parent devices house child devices in device bays. Leave blank '
|
||||
'if this device type is neither a parent nor a child.')
|
||||
)
|
||||
airflow = models.CharField(
|
||||
max_length=50,
|
||||
@@ -314,7 +315,7 @@ class ModuleType(PrimaryModel, WeightMixin):
|
||||
part_number = models.CharField(
|
||||
max_length=50,
|
||||
blank=True,
|
||||
help_text='Discrete part number (optional)'
|
||||
help_text=_('Discrete part number (optional)')
|
||||
)
|
||||
|
||||
# Generic relations
|
||||
@@ -400,7 +401,7 @@ class DeviceRole(OrganizationalModel):
|
||||
vm_role = models.BooleanField(
|
||||
default=True,
|
||||
verbose_name='VM Role',
|
||||
help_text='Virtual machines may be assigned to this role'
|
||||
help_text=_('Virtual machines may be assigned to this role')
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
@@ -419,19 +420,19 @@ class Platform(OrganizationalModel):
|
||||
related_name='platforms',
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='Optionally limit this platform to devices of a certain manufacturer'
|
||||
help_text=_('Optionally limit this platform to devices of a certain manufacturer')
|
||||
)
|
||||
napalm_driver = models.CharField(
|
||||
max_length=50,
|
||||
blank=True,
|
||||
verbose_name='NAPALM driver',
|
||||
help_text='The name of the NAPALM driver to use when interacting with devices'
|
||||
help_text=_('The name of the NAPALM driver to use when interacting with devices')
|
||||
)
|
||||
napalm_args = models.JSONField(
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name='NAPALM arguments',
|
||||
help_text='Additional arguments to pass when initiating the NAPALM driver (JSON format)'
|
||||
help_text=_('Additional arguments to pass when initiating the NAPALM driver (JSON format)')
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
@@ -496,7 +497,7 @@ class Device(PrimaryModel, ConfigContextModel):
|
||||
null=True,
|
||||
unique=True,
|
||||
verbose_name='Asset tag',
|
||||
help_text='A unique tag used to identify this device'
|
||||
help_text=_('A unique tag used to identify this device')
|
||||
)
|
||||
site = models.ForeignKey(
|
||||
to='dcim.Site',
|
||||
@@ -524,7 +525,7 @@ class Device(PrimaryModel, ConfigContextModel):
|
||||
null=True,
|
||||
validators=[MinValueValidator(1), MaxValueValidator(99.5)],
|
||||
verbose_name='Position (U)',
|
||||
help_text='The lowest-numbered unit occupied by the device'
|
||||
help_text=_('The lowest-numbered unit occupied by the device')
|
||||
)
|
||||
face = models.CharField(
|
||||
max_length=50,
|
||||
@@ -929,7 +930,7 @@ class Module(PrimaryModel, ConfigContextModel):
|
||||
null=True,
|
||||
unique=True,
|
||||
verbose_name='Asset tag',
|
||||
help_text='A unique tag used to identify this device'
|
||||
help_text=_('A unique tag used to identify this device')
|
||||
)
|
||||
|
||||
clone_fields = ('device', 'module_type')
|
||||
|
@@ -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.choices import *
|
||||
from netbox.config import ConfigItem
|
||||
@@ -125,7 +126,7 @@ class PowerFeed(PrimaryModel, PathEndpoint, CabledObjectModel):
|
||||
max_utilization = models.PositiveSmallIntegerField(
|
||||
validators=[MinValueValidator(1), MaxValueValidator(100)],
|
||||
default=ConfigItem('POWERFEED_DEFAULT_MAX_UTILIZATION'),
|
||||
help_text="Maximum permissible draw (percentage)"
|
||||
help_text=_("Maximum permissible draw (percentage)")
|
||||
)
|
||||
available_power = models.PositiveIntegerField(
|
||||
default=0,
|
||||
|
@@ -10,6 +10,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.db import models
|
||||
from django.db.models import Count
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
@@ -64,7 +65,7 @@ class Rack(PrimaryModel, WeightMixin):
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name='Facility ID',
|
||||
help_text='Locally-assigned identifier'
|
||||
help_text=_('Locally-assigned identifier')
|
||||
)
|
||||
site = models.ForeignKey(
|
||||
to='dcim.Site',
|
||||
@@ -96,7 +97,7 @@ class Rack(PrimaryModel, WeightMixin):
|
||||
related_name='racks',
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='Functional role'
|
||||
help_text=_('Functional role')
|
||||
)
|
||||
serial = models.CharField(
|
||||
max_length=50,
|
||||
@@ -109,7 +110,7 @@ class Rack(PrimaryModel, WeightMixin):
|
||||
null=True,
|
||||
unique=True,
|
||||
verbose_name='Asset tag',
|
||||
help_text='A unique tag used to identify this rack'
|
||||
help_text=_('A unique tag used to identify this rack')
|
||||
)
|
||||
type = models.CharField(
|
||||
choices=RackTypeChoices,
|
||||
@@ -121,28 +122,28 @@ class Rack(PrimaryModel, WeightMixin):
|
||||
choices=RackWidthChoices,
|
||||
default=RackWidthChoices.WIDTH_19IN,
|
||||
verbose_name='Width',
|
||||
help_text='Rail-to-rail width'
|
||||
help_text=_('Rail-to-rail width')
|
||||
)
|
||||
u_height = models.PositiveSmallIntegerField(
|
||||
default=RACK_U_HEIGHT_DEFAULT,
|
||||
verbose_name='Height (U)',
|
||||
validators=[MinValueValidator(1), MaxValueValidator(100)],
|
||||
help_text='Height in rack units'
|
||||
help_text=_('Height in rack units')
|
||||
)
|
||||
desc_units = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name='Descending units',
|
||||
help_text='Units are numbered top-to-bottom'
|
||||
help_text=_('Units are numbered top-to-bottom')
|
||||
)
|
||||
outer_width = models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='Outer dimension of rack (width)'
|
||||
help_text=_('Outer dimension of rack (width)')
|
||||
)
|
||||
outer_depth = models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='Outer dimension of rack (depth)'
|
||||
help_text=_('Outer dimension of rack (depth)')
|
||||
)
|
||||
outer_unit = models.CharField(
|
||||
max_length=50,
|
||||
@@ -153,8 +154,8 @@ class Rack(PrimaryModel, WeightMixin):
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=(
|
||||
'Maximum depth of a mounted device, in millimeters. For four-post racks, this is the '
|
||||
'distance between the front and rear rails.'
|
||||
_('Maximum depth of a mounted device, in millimeters. For four-post racks, this is the '
|
||||
'distance between the front and rear rails.')
|
||||
)
|
||||
)
|
||||
|
||||
|
@@ -2,6 +2,7 @@ from django.contrib.contenttypes.fields import GenericRelation
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext as _
|
||||
from timezone_field import TimeZoneField
|
||||
|
||||
from dcim.choices import *
|
||||
@@ -178,7 +179,7 @@ class Site(PrimaryModel):
|
||||
facility = models.CharField(
|
||||
max_length=50,
|
||||
blank=True,
|
||||
help_text='Local facility ID or description'
|
||||
help_text=_('Local facility ID or description')
|
||||
)
|
||||
asns = models.ManyToManyField(
|
||||
to='ipam.ASN',
|
||||
@@ -201,14 +202,14 @@ class Site(PrimaryModel):
|
||||
decimal_places=6,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='GPS coordinate (latitude)'
|
||||
help_text=_('GPS coordinate (latitude)')
|
||||
)
|
||||
longitude = models.DecimalField(
|
||||
max_digits=9,
|
||||
decimal_places=6,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text='GPS coordinate (longitude)'
|
||||
help_text=_('GPS coordinate (longitude)')
|
||||
)
|
||||
|
||||
# Generic relations
|
||||
|
Reference in New Issue
Block a user