mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #13132: Wrap verbose_name and other model text with gettext_lazy() (i18n)
--------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@@ -3,7 +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 django.utils.translation import gettext_lazy as _
|
||||
|
||||
from ipam.choices import *
|
||||
from ipam.constants import *
|
||||
@@ -19,6 +19,7 @@ __all__ = (
|
||||
|
||||
class ServiceBase(models.Model):
|
||||
protocol = models.CharField(
|
||||
verbose_name=_('protocol'),
|
||||
max_length=50,
|
||||
choices=ServiceProtocolChoices
|
||||
)
|
||||
@@ -29,7 +30,7 @@ class ServiceBase(models.Model):
|
||||
MaxValueValidator(SERVICE_PORT_MAX)
|
||||
]
|
||||
),
|
||||
verbose_name='Port numbers'
|
||||
verbose_name=_('port numbers')
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -48,6 +49,7 @@ class ServiceTemplate(ServiceBase, PrimaryModel):
|
||||
A template for a Service to be applied to a device or virtual machine.
|
||||
"""
|
||||
name = models.CharField(
|
||||
verbose_name=_('name'),
|
||||
max_length=100,
|
||||
unique=True
|
||||
)
|
||||
@@ -68,7 +70,7 @@ class Service(ServiceBase, PrimaryModel):
|
||||
to='dcim.Device',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='services',
|
||||
verbose_name='device',
|
||||
verbose_name=_('device'),
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
@@ -80,13 +82,14 @@ class Service(ServiceBase, PrimaryModel):
|
||||
blank=True
|
||||
)
|
||||
name = models.CharField(
|
||||
max_length=100
|
||||
max_length=100,
|
||||
verbose_name=_('name')
|
||||
)
|
||||
ipaddresses = models.ManyToManyField(
|
||||
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")
|
||||
)
|
||||
|
||||
@@ -107,6 +110,6 @@ class Service(ServiceBase, PrimaryModel):
|
||||
|
||||
# A Service must belong to a Device *or* to a VirtualMachine
|
||||
if self.device and self.virtual_machine:
|
||||
raise ValidationError("A service cannot be associated with both a device and a virtual machine.")
|
||||
raise ValidationError(_("A service cannot be associated with both a device and a virtual machine."))
|
||||
if not self.device and not self.virtual_machine:
|
||||
raise ValidationError("A service must be associated with either a device or a virtual machine.")
|
||||
raise ValidationError(_("A service must be associated with either a device or a virtual machine."))
|
||||
|
Reference in New Issue
Block a user