13132 add gettext_lazy to models

This commit is contained in:
Arthur 2023-07-11 16:07:49 +07:00 committed by Jeremy Stretch
parent 8b4b331ffd
commit 9f2ae5ffb2
3 changed files with 16 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import uuid
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _
from utilities.fields import RestrictedGenericForeignKey from utilities.fields import RestrictedGenericForeignKey
from ..fields import CachedValueField from ..fields import CachedValueField
@ -18,6 +19,7 @@ class CachedValue(models.Model):
editable=False editable=False
) )
timestamp = models.DateTimeField( timestamp = models.DateTimeField(
verbose_name=_('timestamp'),
auto_now_add=True, auto_now_add=True,
editable=False editable=False
) )
@ -32,13 +34,18 @@ class CachedValue(models.Model):
fk_field='object_id' fk_field='object_id'
) )
field = models.CharField( field = models.CharField(
verbose_name=_('field'),
max_length=200 max_length=200
) )
type = models.CharField( type = models.CharField(
verbose_name=_('type'),
max_length=30 max_length=30
) )
value = CachedValueField() value = CachedValueField(
verbose_name=_('value'),
)
weight = models.PositiveSmallIntegerField( weight = models.PositiveSmallIntegerField(
verbose_name=_('weight'),
default=1000 default=1000
) )

View File

@ -4,6 +4,7 @@ from django.contrib.auth import get_user_model
from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db import models, transaction from django.db import models, transaction
from django.utils.translation import gettext_lazy as _
from extras.choices import ChangeActionChoices from extras.choices import ChangeActionChoices
from netbox.models import ChangeLoggedModel from netbox.models import ChangeLoggedModel
@ -22,10 +23,12 @@ class Branch(ChangeLoggedModel):
A collection of related StagedChanges. A collection of related StagedChanges.
""" """
name = models.CharField( name = models.CharField(
verbose_name=_('name'),
max_length=100, max_length=100,
unique=True unique=True
) )
description = models.CharField( description = models.CharField(
verbose_name=_('description'),
max_length=200, max_length=200,
blank=True blank=True
) )
@ -61,6 +64,7 @@ class StagedChange(ChangeLoggedModel):
related_name='staged_changes' related_name='staged_changes'
) )
action = models.CharField( action = models.CharField(
verbose_name=_('action'),
max_length=20, max_length=20,
choices=ChangeActionChoices choices=ChangeActionChoices
) )
@ -78,6 +82,7 @@ class StagedChange(ChangeLoggedModel):
fk_field='object_id' fk_field='object_id'
) )
data = models.JSONField( data = models.JSONField(
verbose_name=_('data'),
blank=True, blank=True,
null=True null=True
) )

View File

@ -4,7 +4,7 @@ from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.urls import reverse from django.urls import reverse
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.translation import gettext as _ from django.utils.translation import gettext_lazy as _
from taggit.models import TagBase, GenericTaggedItemBase from taggit.models import TagBase, GenericTaggedItemBase
from extras.utils import FeatureQuery from extras.utils import FeatureQuery
@ -28,9 +28,11 @@ class Tag(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel, TagBase):
primary_key=True primary_key=True
) )
color = ColorField( color = ColorField(
verbose_name=_('color'),
default=ColorChoices.COLOR_GREY default=ColorChoices.COLOR_GREY
) )
description = models.CharField( description = models.CharField(
verbose_name=_('description'),
max_length=200, max_length=200,
blank=True, blank=True,
) )