Closes #11325: Move help_texts from model forms to models

This commit is contained in:
jeremystretch 2023-03-01 17:31:54 -05:00
parent 536b46158a
commit c44eb65993
19 changed files with 75 additions and 134 deletions

View File

@ -47,9 +47,6 @@ class CircuitTypeImportForm(NetBoxModelImportForm):
class Meta:
model = CircuitType
fields = ('name', 'slug', 'description', 'tags')
help_texts = {
'name': _('Name of circuit type'),
}
class CircuitImportForm(NetBoxModelImportForm):

View File

@ -37,9 +37,6 @@ class ProviderForm(NetBoxModelForm):
fields = [
'name', 'slug', 'account', 'asns', 'description', 'comments', 'tags',
]
help_texts = {
'name': _("Full name of the provider"),
}
class ProviderNetworkForm(NetBoxModelForm):
@ -96,10 +93,6 @@ class CircuitForm(TenancyForm, NetBoxModelForm):
'cid', 'type', 'provider', 'status', 'install_date', 'termination_date', 'commit_rate', 'description',
'tenant_group', 'tenant', 'comments', 'tags',
]
help_texts = {
'cid': _("Unique circuit ID"),
'commit_rate': _("Committed rate"),
}
widgets = {
'install_date': DatePicker(),
'termination_date': DatePicker(),
@ -166,11 +159,6 @@ class CircuitTerminationForm(NetBoxModelForm):
'provider_network', 'mark_connected', 'port_speed', 'upstream_speed', 'xconnect_id', 'pp_info',
'description', 'tags',
]
help_texts = {
'port_speed': _("Physical circuit speed"),
'xconnect_id': _("ID of the local cross-connect"),
'pp_info': _("Patch panel ID and port number(s)")
}
widgets = {
'port_speed': SelectSpeedWidget(),
'upstream_speed': SelectSpeedWidget(),

View File

@ -34,7 +34,8 @@ class Circuit(PrimaryModel):
"""
cid = models.CharField(
max_length=100,
verbose_name='Circuit ID'
verbose_name='Circuit ID',
help_text=_("Unique circuit ID")
)
provider = models.ForeignKey(
to='circuits.Provider',
@ -71,7 +72,9 @@ class Circuit(PrimaryModel):
commit_rate = models.PositiveIntegerField(
blank=True,
null=True,
verbose_name='Commit rate (Kbps)')
verbose_name='Commit rate (Kbps)',
help_text=_("Committed rate")
)
# Generic relations
contacts = GenericRelation(
@ -160,7 +163,8 @@ class CircuitTermination(
port_speed = models.PositiveIntegerField(
verbose_name='Port speed (Kbps)',
blank=True,
null=True
null=True,
help_text=_("Physical circuit speed")
)
upstream_speed = models.PositiveIntegerField(
blank=True,
@ -171,12 +175,14 @@ class CircuitTermination(
xconnect_id = models.CharField(
max_length=50,
blank=True,
verbose_name='Cross-connect ID'
verbose_name='Cross-connect ID',
help_text=_("ID of the local cross-connect")
)
pp_info = models.CharField(
max_length=100,
blank=True,
verbose_name='Patch panel/port(s)'
verbose_name='Patch panel/port(s)',
help_text=_("Patch panel ID and port number(s)")
)
description = models.CharField(
max_length=200,

View File

@ -1,6 +1,7 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext as _
from netbox.models import PrimaryModel
@ -17,7 +18,8 @@ class Provider(PrimaryModel):
"""
name = models.CharField(
max_length=100,
unique=True
unique=True,
help_text=_("Full name of the provider")
)
slug = models.SlugField(
max_length=100,

View File

@ -394,10 +394,6 @@ class BaseDeviceImportForm(NetBoxModelImportForm):
class Meta:
fields = []
model = Device
help_texts = {
'vc_position': 'Virtual chassis position',
'vc_priority': 'Virtual chassis priority',
}
def __init__(self, data=None, *args, **kwargs):
super().__init__(data, *args, **kwargs)
@ -775,9 +771,6 @@ class FrontPortImportForm(NetBoxModelImportForm):
'device', 'name', 'label', 'type', 'color', 'mark_connected', 'rear_port', 'rear_port_position',
'description', 'tags'
)
help_texts = {
'rear_port_position': _('Mapped position on corresponding rear port'),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -815,9 +808,6 @@ class RearPortImportForm(NetBoxModelImportForm):
class Meta:
model = RearPort
fields = ('device', 'name', 'label', 'type', 'color', 'mark_connected', 'positions', 'description', 'tags')
help_texts = {
'positions': _('Number of front ports which may be mapped')
}
class ModuleBayImportForm(NetBoxModelImportForm):
@ -1204,4 +1194,3 @@ class VirtualDeviceContextImportForm(NetBoxModelImportForm):
'name', 'device', 'status', 'tenant', 'identifier', 'comments',
]
model = VirtualDeviceContext
help_texts = {}

View File

@ -66,12 +66,6 @@ __all__ = (
'VirtualDeviceContextForm'
)
INTERFACE_MODE_HELP_TEXT = """
Access: One untagged VLAN<br />
Tagged: One untagged VLAN and/or one or more tagged VLANs<br />
Tagged (All): Implies all VLANs are available (w/optional untagged VLAN)
"""
class RegionForm(NetBoxModelForm):
parent = DynamicModelChoiceField(
@ -160,16 +154,6 @@ class SiteForm(TenancyForm, NetBoxModelForm):
}
),
}
help_texts = {
'name': _("Full name of the site"),
'facility': _("Data center provider and facility (e.g. Equinix NY7)"),
'time_zone': _("Local time zone"),
'description': _("Short description (will appear in sites list)"),
'physical_address': _("Physical location of the building (e.g. for GPS)"),
'shipping_address': _("If different from the physical address"),
'latitude': _("Latitude in decimal format (xx.yyyyyy)"),
'longitude': _("Longitude in decimal format (xx.yyyyyy)")
}
class LocationForm(TenancyForm, NetBoxModelForm):
@ -276,12 +260,6 @@ class RackForm(TenancyForm, NetBoxModelForm):
'role', 'serial', 'asset_tag', 'type', 'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth',
'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
]
help_texts = {
'site': _("The site at which the rack exists"),
'name': _("Organizational rack name"),
'facility_id': _("The unique rack ID assigned by the facility"),
'u_height': _("Height in rack units"),
}
class RackReservationForm(TenancyForm, NetBoxModelForm):
@ -583,12 +561,6 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
'cluster_group', 'cluster', 'tenant_group', 'tenant', 'virtual_chassis', 'vc_position', 'vc_priority',
'description', 'config_template', 'comments', 'tags', 'local_context_data'
]
help_texts = {
'device_role': _("The function this device serves"),
'serial': _("Chassis serial number"),
'local_context_data': _("Local config context data overwrites all source contexts in the final rendered "
"config context"),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -1374,11 +1346,6 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
labels = {
'mode': '802.1Q Mode',
}
help_texts = {
'mode': INTERFACE_MODE_HELP_TEXT,
'rf_channel_frequency': _("Populated by selected channel (if set)"),
'rf_channel_width': _("Populated by selected channel (if set)"),
}
class FrontPortForm(ModularDeviceComponentForm):

View File

@ -478,7 +478,8 @@ class BaseInterface(models.Model):
mode = models.CharField(
max_length=50,
choices=InterfaceModeChoices,
blank=True
blank=True,
help_text=_("IEEE 802.1Q tagging strategy")
)
parent = models.ForeignKey(
to='self',
@ -587,14 +588,16 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
decimal_places=2,
blank=True,
null=True,
verbose_name='Channel frequency (MHz)'
verbose_name='Channel frequency (MHz)',
help_text=_("Populated by selected channel (if set)")
)
rf_channel_width = models.DecimalField(
max_digits=7,
decimal_places=3,
blank=True,
null=True,
verbose_name='Channel width (MHz)'
verbose_name='Channel width (MHz)',
help_text=_("Populated by selected channel (if set)")
)
tx_power = models.PositiveSmallIntegerField(
blank=True,
@ -885,7 +888,8 @@ class FrontPort(ModularComponentModel, CabledObjectModel):
validators=[
MinValueValidator(REARPORT_POSITIONS_MIN),
MaxValueValidator(REARPORT_POSITIONS_MAX)
]
],
help_text=_('Mapped position on corresponding rear port')
)
clone_fields = ('device', 'type', 'color')
@ -940,7 +944,8 @@ class RearPort(ModularComponentModel, CabledObjectModel):
validators=[
MinValueValidator(REARPORT_POSITIONS_MIN),
MaxValueValidator(REARPORT_POSITIONS_MAX)
]
],
help_text=_('Number of front ports which may be mapped')
)
clone_fields = ('device', 'type', 'color', 'positions')

View File

@ -480,7 +480,8 @@ class Device(PrimaryModel, ConfigContextModel):
device_role = models.ForeignKey(
to='dcim.DeviceRole',
on_delete=models.PROTECT,
related_name='devices'
related_name='devices',
help_text=_("The function this device serves")
)
tenant = models.ForeignKey(
to='tenancy.Tenant',
@ -510,7 +511,8 @@ class Device(PrimaryModel, ConfigContextModel):
serial = models.CharField(
max_length=50,
blank=True,
verbose_name='Serial number'
verbose_name='Serial number',
help_text=_("Chassis serial number, assigned by the manufacturer")
)
asset_tag = models.CharField(
max_length=50,
@ -597,12 +599,14 @@ class Device(PrimaryModel, ConfigContextModel):
vc_position = models.PositiveSmallIntegerField(
blank=True,
null=True,
validators=[MaxValueValidator(255)]
validators=[MaxValueValidator(255)],
help_text=_('Virtual chassis position')
)
vc_priority = models.PositiveSmallIntegerField(
blank=True,
null=True,
validators=[MaxValueValidator(255)]
validators=[MaxValueValidator(255)],
help_text=_('Virtual chassis master election priority')
)
config_template = models.ForeignKey(
to='extras.ConfigTemplate',

View File

@ -64,7 +64,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',

View File

@ -139,7 +139,8 @@ class Site(PrimaryModel):
"""
name = models.CharField(
max_length=100,
unique=True
unique=True,
help_text=_("Full name of the site")
)
_name = NaturalOrderingField(
target_field='name',
@ -179,7 +180,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',
@ -191,25 +192,27 @@ class Site(PrimaryModel):
)
physical_address = models.CharField(
max_length=200,
blank=True
blank=True,
help_text=_("Physical location of the building")
)
shipping_address = models.CharField(
max_length=200,
blank=True
blank=True,
help_text=_("If different from the physical address")
)
latitude = models.DecimalField(
max_digits=8,
decimal_places=6,
blank=True,
null=True,
help_text=_('GPS coordinate (latitude)')
help_text=_("GPS coordinate in decimal format (xx.yyyyyy)")
)
longitude = models.DecimalField(
max_digits=9,
decimal_places=6,
blank=True,
null=True,
help_text=_('GPS coordinate (longitude)')
help_text=_("GPS coordinate in decimal format (xx.yyyyyy)")
)
# Generic relations

View File

@ -56,8 +56,10 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm):
model = CustomField
fields = '__all__'
help_texts = {
'type': _("The type of data stored in this field. For object/multi-object fields, select the related object "
"type below.")
'type': _(
"The type of data stored in this field. For object/multi-object fields, select the related object "
"type below."
)
}
@ -80,9 +82,11 @@ class CustomLinkForm(BootstrapMixin, forms.ModelForm):
'link_url': forms.Textarea(attrs={'class': 'font-monospace'}),
}
help_texts = {
'link_text': _('Jinja2 template code for the link text. Reference the object as <code>{{ object }}</code>. '
'Links which render as empty text will not be displayed.'),
'link_url': _('Jinja2 template code for the link URL. Reference the object as <code>{{ object }}</code>.'),
'link_text': _(
"Jinja2 template code for the link text. Reference the object as <code>{{ object }}</code>. Links "
"which render as empty text will not be displayed."
),
'link_url': _("Jinja2 template code for the link URL. Reference the object as <code>{{ object }}</code>."),
}

View File

@ -152,6 +152,9 @@ class ConfigContextModel(models.Model):
local_context_data = models.JSONField(
blank=True,
null=True,
help_text=_(
"Local config context data takes precedence over source contexts in the final rendered config context"
)
)
class Meta:

View File

@ -65,9 +65,6 @@ class RIRImportForm(NetBoxModelImportForm):
class Meta:
model = RIR
fields = ('name', 'slug', 'is_private', 'description', 'tags')
help_texts = {
'name': _('RIR name'),
}
class AggregateImportForm(NetBoxModelImportForm):
@ -410,10 +407,6 @@ class VLANImportForm(NetBoxModelImportForm):
class Meta:
model = VLAN
fields = ('site', 'group', 'vid', 'name', 'tenant', 'status', 'role', 'description', 'comments', 'tags')
help_texts = {
'vid': 'Numeric VLAN ID (1-4094)',
'name': 'VLAN name',
}
class ServiceTemplateImportForm(NetBoxModelImportForm):

View File

@ -68,9 +68,6 @@ class VRFForm(TenancyForm, NetBoxModelForm):
labels = {
'rd': "RD",
}
help_texts = {
'rd': _("Route distinguisher in any format"),
}
class RouteTargetForm(TenancyForm, NetBoxModelForm):
@ -120,10 +117,6 @@ class AggregateForm(TenancyForm, NetBoxModelForm):
fields = [
'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"),
}
widgets = {
'date_added': DatePicker(),
}
@ -169,10 +162,6 @@ class ASNForm(TenancyForm, NetBoxModelForm):
fields = [
'asn', 'rir', 'sites', 'tenant_group', 'tenant', 'description', 'comments', 'tags'
]
help_texts = {
'asn': _("AS number"),
'rir': _("Regional Internet Registry responsible for this prefix"),
}
widgets = {
'date_added': DatePicker(),
}
@ -788,14 +777,6 @@ class VLANForm(TenancyForm, NetBoxModelForm):
'site', 'group', 'vid', 'name', 'status', 'role', 'tenant_group', 'tenant', 'description', 'comments',
'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"),
}
class ServiceTemplateForm(NetBoxModelForm):
@ -851,10 +832,6 @@ class ServiceForm(NetBoxModelForm):
fields = [
'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."),
}
class ServiceCreateForm(ServiceForm):

View File

@ -87,12 +87,13 @@ class ASN(PrimaryModel):
to='ipam.RIR',
on_delete=models.PROTECT,
related_name='asns',
verbose_name='RIR'
verbose_name='RIR',
help_text=_("Regional Internet Registry responsible for this AS number space")
)
asn = ASNField(
unique=True,
verbose_name='ASN',
help_text=_('32-bit autonomous system number')
help_text=_('16- or 32-bit autonomous system number')
)
tenant = models.ForeignKey(
to='tenancy.Tenant',

View File

@ -77,12 +77,15 @@ class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):
An aggregate exists at the root level of the IP address space hierarchy in NetBox. Aggregates are used to organize
the hierarchy and track the overall utilization of available address space. Each Aggregate is assigned to a RIR.
"""
prefix = IPNetworkField()
prefix = IPNetworkField(
help_text=_("IPv4 or IPv6 network")
)
rir = models.ForeignKey(
to='ipam.RIR',
on_delete=models.PROTECT,
related_name='aggregates',
verbose_name='RIR'
verbose_name='RIR',
help_text=_("Regional Internet Registry responsible for this IP space")
)
tenant = models.ForeignKey(
to='tenancy.Tenant',

View File

@ -3,6 +3,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 ipam.choices import *
from ipam.constants import *
@ -85,7 +86,8 @@ class Service(ServiceBase, PrimaryModel):
to='ipam.IPAddress',
related_name='services',
blank=True,
verbose_name='IP addresses'
verbose_name='IP addresses',
help_text=_("The specific IP addresses (if any) to which this service is bound")
)
clone_fields = ['protocol', 'ports', 'description', 'device', 'virtual_machine', 'ipaddresses', ]

View File

@ -129,21 +129,24 @@ class VLAN(PrimaryModel):
on_delete=models.PROTECT,
related_name='vlans',
blank=True,
null=True
null=True,
help_text=_("The specific site to which this VLAN is assigned (if any)")
)
group = models.ForeignKey(
to='ipam.VLANGroup',
on_delete=models.PROTECT,
related_name='vlans',
blank=True,
null=True
null=True,
help_text=_("VLAN group (optional)")
)
vid = models.PositiveSmallIntegerField(
verbose_name='ID',
validators=(
MinValueValidator(VLAN_VID_MIN),
MaxValueValidator(VLAN_VID_MAX)
)
),
help_text=_("Numeric VLAN ID (1-4094)")
)
name = models.CharField(
max_length=64
@ -158,14 +161,16 @@ class VLAN(PrimaryModel):
status = models.CharField(
max_length=50,
choices=VLANStatusChoices,
default=VLANStatusChoices.STATUS_ACTIVE
default=VLANStatusChoices.STATUS_ACTIVE,
help_text=_("Operational status of this VLAN")
)
role = models.ForeignKey(
to='ipam.Role',
on_delete=models.SET_NULL,
related_name='vlans',
blank=True,
null=True
null=True,
help_text=_("The primary function of this VLAN")
)
l2vpn_terminations = GenericRelation(

View File

@ -4,7 +4,6 @@ from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _
from dcim.forms.common import InterfaceCommonForm
from dcim.forms.model_forms import INTERFACE_MODE_HELP_TEXT
from dcim.models import Device, DeviceRole, Platform, Rack, Region, Site, SiteGroup
from ipam.models import IPAddress, VLAN, VLANGroup, VRF
from netbox.forms import NetBoxModelForm
@ -237,10 +236,6 @@ class VirtualMachineForm(TenancyForm, NetBoxModelForm):
'platform', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'comments', 'tags',
'local_context_data',
]
help_texts = {
'local_context_data': _("Local config context data overwrites all sources contexts in the final rendered "
"config context"),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -358,9 +353,6 @@ class VMInterfaceForm(InterfaceCommonForm, NetBoxModelForm):
}
),
}
help_texts = {
'mode': INTERFACE_MODE_HELP_TEXT,
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)