1
0
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:
Arthur Hanson
2023-07-31 22:28:07 +07:00
committed by GitHub
parent 80376abedf
commit 83bebc1bd2
36 changed files with 899 additions and 431 deletions

View File

@@ -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_lazy as _
from dcim.models import Device
from netbox.models import OrganizationalModel, PrimaryModel
@@ -46,9 +47,11 @@ class Cluster(PrimaryModel):
A cluster of VirtualMachines. Each Cluster may optionally be associated with one or more Devices.
"""
name = models.CharField(
verbose_name=_('name'),
max_length=100
)
type = models.ForeignKey(
verbose_name=_('type'),
to=ClusterType,
on_delete=models.PROTECT,
related_name='clusters'
@@ -61,6 +64,7 @@ class Cluster(PrimaryModel):
null=True
)
status = models.CharField(
verbose_name=_('status'),
max_length=50,
choices=ClusterStatusChoices,
default=ClusterStatusChoices.STATUS_ACTIVE
@@ -128,7 +132,7 @@ class Cluster(PrimaryModel):
nonsite_devices = Device.objects.filter(cluster=self).exclude(site=self.site).count()
if nonsite_devices:
raise ValidationError({
'site': "{} devices are assigned as hosts for this cluster but are not in site {}".format(
'site': _("{} devices are assigned as hosts for this cluster but are not in site {}").format(
nonsite_devices, self.site
)
})