Moved description max length to constant

This commit is contained in:
Saria Hajjar 2020-01-25 18:14:05 +00:00
parent 7a548e806d
commit dbc721fc2a
14 changed files with 64 additions and 46 deletions

View File

@ -2,6 +2,7 @@ from django import forms
from taggit.forms import TagField
from dcim.models import Region, Site
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.forms import AddRemoveTagsForm, CustomFieldForm, CustomFieldBulkEditForm, CustomFieldFilterForm
from tenancy.forms import TenancyFilterForm, TenancyForm
from tenancy.models import Tenant
@ -263,7 +264,7 @@ class CircuitBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEdit
label='Commit rate (Kbps)'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
comments = CommentField(

View File

@ -6,6 +6,7 @@ from taggit.managers import TaggableManager
from dcim.constants import CONNECTION_STATUS_CHOICES
from dcim.fields import ASNField
from dcim.models import CableTermination
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.models import CustomFieldModel, ObjectChange, TaggedItem
from utilities.models import ChangeLoggedModel
from utilities.utils import serialize_object
@ -107,7 +108,7 @@ class CircuitType(ChangeLoggedModel):
unique=True
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True,
)
@ -172,7 +173,7 @@ class Circuit(ChangeLoggedModel, CustomFieldModel):
null=True,
verbose_name='Commit rate (Kbps)')
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
comments = models.TextField(
@ -290,7 +291,7 @@ class CircuitTermination(CableTermination):
verbose_name='Patch panel/port(s)'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)

View File

@ -12,6 +12,7 @@ from taggit.forms import TagField
from timezone_field import TimeZoneFormField
from circuits.models import Circuit, Provider
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.forms import (
AddRemoveTagsForm, CustomFieldForm, CustomFieldBulkEditForm, CustomFieldFilterForm, LocalConfigContextFilterForm
)
@ -330,7 +331,7 @@ class SiteBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditFor
label='ASN'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
time_zone = TimeZoneFormField(
@ -834,7 +835,7 @@ class RackReservationBulkEditForm(BootstrapMixin, BulkEditForm):
)
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -2141,7 +2142,7 @@ class DeviceBulkAddInterfaceForm(DeviceBulkAddComponentForm):
label='Management only'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -2180,7 +2181,7 @@ class ConsolePortCreateForm(ComponentForm):
widget=StaticSelect2()
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
tags = TagField(
@ -2237,7 +2238,7 @@ class ConsoleServerPortCreateForm(ComponentForm):
widget=StaticSelect2()
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
tags = TagField(
@ -2256,7 +2257,7 @@ class ConsoleServerPortBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditF
widget=StaticSelect2()
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -2339,7 +2340,7 @@ class PowerPortCreateForm(ComponentForm):
help_text="Allocated draw in watts"
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
tags = TagField(
@ -2417,7 +2418,7 @@ class PowerOutletCreateForm(ComponentForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
tags = TagField(
@ -2500,7 +2501,7 @@ class PowerOutletBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -2633,7 +2634,7 @@ class InterfaceCreateForm(InterfaceCommonForm, ComponentForm, forms.Form):
help_text='This interface is used only for out-of-band management'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
mode = forms.ChoiceField(
@ -2784,7 +2785,7 @@ class InterfaceBulkEditForm(InterfaceCommonForm, BootstrapMixin, AddRemoveTagsFo
label='Management only'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
mode = forms.ChoiceField(
@ -2893,6 +2894,7 @@ class FrontPortCreateForm(ComponentForm):
help_text='Select one rear port assignment for each front port being created.',
)
description = forms.CharField(
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -2997,7 +2999,7 @@ class FrontPortBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
widget=StaticSelect2()
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -3060,6 +3062,7 @@ class RearPortCreateForm(ComponentForm):
help_text='The number of front ports which may be mapped to each rear port'
)
description = forms.CharField(
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -3093,7 +3096,7 @@ class RearPortBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
widget=StaticSelect2()
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -3869,7 +3872,7 @@ class InventoryItemBulkEditForm(BootstrapMixin, BulkEditForm):
label='Part ID'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)

View File

@ -21,6 +21,7 @@ from timezone_field import TimeZoneField
from dcim.choices import *
from dcim.constants import *
from dcim.fields import ASNField
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.models import ConfigContextModel, CustomFieldModel, TaggedItem
from utilities.fields import ColorField
from utilities.managers import NaturalOrderingManager
@ -169,7 +170,7 @@ class Site(ChangeLoggedModel, CustomFieldModel):
blank=True
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
physical_address = models.CharField(
@ -324,7 +325,7 @@ class RackRole(ChangeLoggedModel):
)
color = ColorField()
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True,
)
@ -882,7 +883,7 @@ class RackReservation(ChangeLoggedModel):
on_delete=models.PROTECT
)
description = models.CharField(
max_length=100
max_length=DESCRIPTION_MAX_LENGTH
)
class Meta:
@ -1197,7 +1198,7 @@ class DeviceRole(ChangeLoggedModel):
help_text='Virtual machines may be assigned to this role'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True,
)

View File

@ -11,6 +11,7 @@ from dcim.constants import *
from dcim.exceptions import LoopDetected
from dcim.fields import MACAddressField
from dcim.managers import InterfaceManager
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.models import ObjectChange, TaggedItem
from utilities.managers import NaturalOrderingManager
from utilities.utils import serialize_object
@ -33,7 +34,7 @@ __all__ = (
class ComponentModel(models.Model):
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)

View File

@ -1,6 +1,9 @@
from django.db.models import Q
# General constants
DESCRIPTION_MAX_LENGTH = 100
# Models which support custom fields
CUSTOMFIELD_MODELS = Q(
Q(app_label='circuits', model__in=[

View File

@ -14,6 +14,7 @@ from utilities.forms import (
SlugField, StaticSelect2, BOOLEAN_WITH_BLANK_CHOICES,
)
from .choices import *
from .constants import *
from .models import ConfigContext, CustomField, CustomFieldValue, ImageAttachment, ObjectChange, Tag
@ -294,7 +295,7 @@ class ConfigContextBulkEditForm(BootstrapMixin, BulkEditForm):
)
description = forms.CharField(
required=False,
max_length=100
max_length=DESCRIPTION_MAX_LENGTH
)
class Meta:

View File

@ -213,7 +213,7 @@ class CustomField(models.Model):
'the field\'s name will be used)'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
required = models.BooleanField(
@ -489,7 +489,7 @@ class ExportTemplate(models.Model):
max_length=100
)
description = models.CharField(
max_length=200,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
template_language = models.CharField(
@ -668,7 +668,7 @@ class ConfigContext(models.Model):
default=1000
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
is_active = models.BooleanField(

View File

@ -4,6 +4,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
from taggit.forms import TagField
from dcim.models import Device, Interface, Rack, Region, Site
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.forms import AddRemoveTagsForm, CustomFieldForm, CustomFieldBulkEditForm, CustomFieldFilterForm
from tenancy.forms import TenancyFilterForm, TenancyForm
from tenancy.models import Tenant
@ -86,7 +87,7 @@ class VRFBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm
label='Enforce unique space'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -198,7 +199,7 @@ class AggregateBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEd
required=False
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -480,7 +481,7 @@ class PrefixBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditF
label='Is a pool'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -923,7 +924,7 @@ class IPAddressBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEd
required=False
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -1229,7 +1230,7 @@ class VLANBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditFor
)
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
@ -1373,7 +1374,7 @@ class ServiceBulkEditForm(BootstrapMixin, CustomFieldBulkEditForm):
required=False
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)

View File

@ -9,6 +9,7 @@ from django.urls import reverse
from taggit.managers import TaggableManager
from dcim.models import Device, Interface
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.models import CustomFieldModel, ObjectChange, TaggedItem
from utilities.models import ChangeLoggedModel
from utilities.utils import serialize_object
@ -63,7 +64,7 @@ class VRF(ChangeLoggedModel, CustomFieldModel):
help_text='Prevent duplicate prefixes/IP addresses within this VRF'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
custom_field_values = GenericRelation(
@ -165,7 +166,7 @@ class Aggregate(ChangeLoggedModel, CustomFieldModel):
null=True
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
custom_field_values = GenericRelation(
@ -264,7 +265,7 @@ class Role(ChangeLoggedModel):
default=1000
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True,
)
@ -349,7 +350,7 @@ class Prefix(ChangeLoggedModel, CustomFieldModel):
help_text='All IP addresses within this prefix are considered usable'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
custom_field_values = GenericRelation(
@ -620,7 +621,7 @@ class IPAddress(ChangeLoggedModel, CustomFieldModel):
help_text='Hostname or FQDN (not case-sensitive)'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
custom_field_values = GenericRelation(
@ -904,7 +905,7 @@ class VLAN(ChangeLoggedModel, CustomFieldModel):
null=True
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
custom_field_values = GenericRelation(
@ -1016,7 +1017,7 @@ class Service(ChangeLoggedModel, CustomFieldModel):
verbose_name='IP addresses'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)
custom_field_values = GenericRelation(

View File

@ -15,6 +15,7 @@ from django.utils.encoding import force_bytes
from taggit.managers import TaggableManager
from dcim.models import Device
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.models import CustomFieldModel, TaggedItem
from utilities.models import ChangeLoggedModel
from .exceptions import InvalidKey
@ -254,7 +255,7 @@ class SecretRole(ChangeLoggedModel):
unique=True
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True,
)
users = models.ManyToManyField(

View File

@ -3,6 +3,7 @@ from django.db import models
from django.urls import reverse
from taggit.managers import TaggableManager
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.models import CustomFieldModel, TaggedItem
from utilities.models import ChangeLoggedModel
@ -63,7 +64,7 @@ class Tenant(ChangeLoggedModel, CustomFieldModel):
null=True
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True,
help_text='Long-form name (optional)'
)

View File

@ -6,6 +6,8 @@ from django.core.validators import MinLengthValidator
from django.db import models
from django.utils import timezone
from extras.constants import DESCRIPTION_MAX_LENGTH
__all__ = (
'Token',
@ -39,7 +41,7 @@ class Token(models.Model):
help_text='Permit create/update/delete operations using this key'
)
description = models.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
blank=True
)

View File

@ -6,6 +6,7 @@ from dcim.choices import InterfaceModeChoices
from dcim.constants import INTERFACE_MTU_MAX, INTERFACE_MTU_MIN
from dcim.forms import INTERFACE_MODE_HELP_TEXT
from dcim.models import Device, DeviceRole, Interface, Platform, Rack, Region, Site
from extras.constants import DESCRIPTION_MAX_LENGTH
from extras.forms import AddRemoveTagsForm, CustomFieldBulkEditForm, CustomFieldForm, CustomFieldFilterForm
from ipam.models import IPAddress, VLANGroup, VLAN
from tenancy.forms import TenancyFilterForm, TenancyForm
@ -755,7 +756,7 @@ class InterfaceCreateForm(ComponentForm):
label='MAC Address'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
mode = forms.ChoiceField(
@ -840,7 +841,7 @@ class InterfaceBulkEditForm(BootstrapMixin, BulkEditForm):
label='MTU'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)
mode = forms.ChoiceField(
@ -937,6 +938,6 @@ class VirtualMachineBulkAddInterfaceForm(VirtualMachineBulkAddComponentForm):
label='MTU'
)
description = forms.CharField(
max_length=100,
max_length=DESCRIPTION_MAX_LENGTH,
required=False
)