content: from django import forms
  from django.conf import settings
  from django.utils.translation import gettext_lazy as _
  from timezone_field import TimeZoneFormField
  
  from dcim.choices import *
  from dcim.constants import *
  from dcim.models import *
  from extras.models import ConfigTemplate
  from ipam.choices import VLANQinQRoleChoices
  from ipam.models import ASN, VLAN, VLANGroup, VRF
  from netbox.choices import *
  from netbox.forms import NetBoxModelBulkEditForm
  from netbox.forms.mixins import ChangelogMessageMixin
  from tenancy.models import Tenant
  from users.models import User
  from utilities.forms import BulkEditForm, add_blank_choice, form_from_model
  from utilities.forms.fields import (
      ColorField, CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, JSONField,
  )
  from utilities.forms.rendering import FieldSet, InlineFields, TabbedGroups
  from utilities.forms.widgets import BulkEditNullBooleanSelect, NumberWithOptions
  from virtualization.models import Cluster
  from wireless.choices import WirelessRoleChoices
  from wireless.models import WirelessLAN, WirelessLANGroup
  
  __all__ = (
      'CableBulkEditForm',
      'ConsolePortBulkEditForm',
      'ConsolePortTemplateBulkEditForm',
      'ConsoleServerPortBulkEditForm',
      'ConsoleServerPortTemplateBulkEditForm',
      'DeviceBayBulkEditForm',
      'DeviceBayTemplateBulkEditForm',
      'DeviceBulkEditForm',
      'DeviceRoleBulkEditForm',
      'DeviceTypeBulkEditForm',
      'FrontPortBulkEditForm',
      'FrontPortTemplateBulkEditForm',
      'InterfaceBulkEditForm',
      'InterfaceTemplateBulkEditForm',
      'InventoryItemBulkEditForm',
      'InventoryItemRoleBulkEditForm',
      'InventoryItemTemplateBulkEditForm',
      'LocationBulkEditForm',
      'MACAddressBulkEditForm',
      'ManufacturerBulkEditForm',
      'ModuleBulkEditForm',
      'ModuleBayBulkEditForm',
      'ModuleBayTemplateBulkEditForm',
      'ModuleTypeBulkEditForm',
      'ModuleTypeProfileBulkEditForm',
      'PlatformBulkEditForm',
      'PowerFeedBulkEditForm',
      'PowerOutletBulkEditForm',
      'PowerOutletTemplateBulkEditForm',
      'PowerPanelBulkEditForm',
      'PowerPortBulkEditForm',
      'PowerPortTemplateBulkEditForm',
      'RackBulkEditForm',
      'RackReservationBulkEditForm',
      'RackRoleBulkEditForm',
      'RackTypeBulkEditForm',
      'RearPortBulkEditForm',
      'RearPortTemplateBulkEditForm',
      'RegionBulkEditForm',
      'SiteBulkEditForm',
      'SiteGroupBulkEditForm',
      'VirtualChassisBulkEditForm',
      'VirtualDeviceContextBulkEditForm'
  )
  
  
  class RegionBulkEditForm(NetBoxModelBulkEditForm):
      parent = DynamicModelChoiceField(
          label=_('Parent'),
          queryset=Region.objects.all(),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Region
      fieldsets = (
          FieldSet('parent', 'description'),
      )
      nullable_fields = ('parent', 'description', 'comments')
  
  
  class SiteGroupBulkEditForm(NetBoxModelBulkEditForm):
      parent = DynamicModelChoiceField(
          label=_('Parent'),
          queryset=SiteGroup.objects.all(),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = SiteGroup
      fieldsets = (
          FieldSet('parent', 'description'),
      )
      nullable_fields = ('parent', 'description', 'comments')
  
  
  class SiteBulkEditForm(NetBoxModelBulkEditForm):
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(SiteStatusChoices),
          required=False,
          initial=''
      )
      region = DynamicModelChoiceField(
          label=_('Region'),
          queryset=Region.objects.all(),
          required=False
      )
      group = DynamicModelChoiceField(
          label=_('Group'),
          queryset=SiteGroup.objects.all(),
          required=False
      )
      tenant = DynamicModelChoiceField(
          label=_('Tenant'),
          queryset=Tenant.objects.all(),
          required=False
      )
      facility = forms.CharField(
          label=_('Facility'),
          max_length=50,
          required=False
      )
      asns = DynamicModelMultipleChoiceField(
          queryset=ASN.objects.all(),
          label=_('ASNs'),
          required=False
      )
      contact_name = forms.CharField(
          label=_('Contact name'),
          max_length=50,
          required=False
      )
      contact_phone = forms.CharField(
          label=_('Contact phone'),
          max_length=20,
          required=False
      )
      contact_email = forms.EmailField(
          required=False,
          label=_('Contact E-mail')
      )
      time_zone = TimeZoneFormField(
          label=_('Time zone'),
          choices=add_blank_choice(TimeZoneFormField().choices),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Site
      fieldsets = (
          FieldSet('status', 'region', 'group', 'tenant', 'facility', 'asns', 'time_zone', 'description'),
      )
      nullable_fields = (
          'region', 'group', 'tenant', 'facility', 'asns', 'time_zone', 'description', 'comments',
      )
  
  
  class LocationBulkEditForm(NetBoxModelBulkEditForm):
      site = DynamicModelChoiceField(
          label=_('Site'),
          queryset=Site.objects.all(),
          required=False
      )
      parent = DynamicModelChoiceField(
          label=_('Parent'),
          queryset=Location.objects.all(),
          required=False,
          query_params={
              'site_id': '$site'
          }
      )
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(LocationStatusChoices),
          required=False,
          initial=''
      )
      tenant = DynamicModelChoiceField(
          label=_('Tenant'),
          queryset=Tenant.objects.all(),
          required=False
      )
      facility = forms.CharField(
          label=_('Facility'),
          max_length=50,
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Location
      fieldsets = (
          FieldSet('site', 'parent', 'status', 'tenant', 'facility', 'description'),
      )
      nullable_fields = ('parent', 'tenant', 'facility', 'description', 'comments')
  
  
  class RackRoleBulkEditForm(NetBoxModelBulkEditForm):
      color = ColorField(
          label=_('Color'),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
  
      model = RackRole
      fieldsets = (
          FieldSet('color', 'description'),
      )
      nullable_fields = ('color', 'description')
  
  
  class RackTypeBulkEditForm(NetBoxModelBulkEditForm):
      manufacturer = DynamicModelChoiceField(
          label=_('Manufacturer'),
          queryset=Manufacturer.objects.all(),
          required=False
      )
      form_factor = forms.ChoiceField(
          label=_('Form factor'),
          choices=add_blank_choice(RackFormFactorChoices),
          required=False
      )
      width = forms.ChoiceField(
          label=_('Width'),
          choices=add_blank_choice(RackWidthChoices),
          required=False
      )
      u_height = forms.IntegerField(
          required=False,
          label=_('Height (U)')
      )
      starting_unit = forms.IntegerField(
          required=False,
          min_value=1
      )
      desc_units = forms.NullBooleanField(
          required=False,
          widget=BulkEditNullBooleanSelect,
          label=_('Descending units')
      )
      outer_width = forms.IntegerField(
          label=_('Outer width'),
          required=False,
          min_value=1
      )
      outer_height = forms.IntegerField(
          label=_('Outer height'),
          required=False,
          min_value=1
      )
      outer_depth = forms.IntegerField(
          label=_('Outer depth'),
          required=False,
          min_value=1
      )
      outer_unit = forms.ChoiceField(
          label=_('Outer unit'),
          choices=add_blank_choice(RackDimensionUnitChoices),
          required=False
      )
      mounting_depth = forms.IntegerField(
          label=_('Mounting depth'),
          required=False,
          min_value=1
      )
      weight = forms.DecimalField(
          label=_('Weight'),
          min_value=0,
          required=False
      )
      max_weight = forms.IntegerField(
          label=_('Max weight'),
          min_value=0,
          required=False
      )
      weight_unit = forms.ChoiceField(
          label=_('Weight unit'),
          choices=add_blank_choice(WeightUnitChoices),
          required=False,
          initial=''
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = RackType
      fieldsets = (
          FieldSet('manufacturer', 'description', 'form_factor', 'width', 'u_height', name=_('Rack Type')),
          FieldSet(
              InlineFields('outer_width', 'outer_height', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')),
              InlineFields('weight', 'max_weight', 'weight_unit', label=_('Weight')),
              'mounting_depth',
              name=_('Dimensions')
          ),
          FieldSet('starting_unit', 'desc_units', name=_('Numbering')),
      )
      nullable_fields = (
          'outer_width', 'outer_height', 'outer_depth', 'outer_unit', 'weight',
          'max_weight', 'weight_unit', 'description', 'comments',
      )
  
  
  class RackBulkEditForm(NetBoxModelBulkEditForm):
      region = DynamicModelChoiceField(
          label=_('Region'),
          queryset=Region.objects.all(),
          required=False,
          initial_params={
              'sites': '$site'
          }
      )
      site_group = DynamicModelChoiceField(
          label=_('Site group'),
          queryset=SiteGroup.objects.all(),
          required=False,
          initial_params={
              'sites': '$site'
          }
      )
      site = DynamicModelChoiceField(
          label=_('Site'),
          queryset=Site.objects.all(),
          required=False,
          query_params={
              'region_id': '$region',
              'group_id': '$site_group',
          }
      )
      location = DynamicModelChoiceField(
          label=_('Location'),
          queryset=Location.objects.all(),
          required=False,
          query_params={
              'site_id': '$site'
          }
      )
      tenant = DynamicModelChoiceField(
          label=_('Tenant'),
          queryset=Tenant.objects.all(),
          required=False
      )
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(RackStatusChoices),
          required=False,
          initial=''
      )
      role = DynamicModelChoiceField(
          label=_('Role'),
          queryset=RackRole.objects.all(),
          required=False
      )
      rack_type = DynamicModelChoiceField(
          label=_('Rack type'),
          queryset=RackType.objects.all(),
          required=False,
      )
      serial = forms.CharField(
          max_length=50,
          required=False,
          label=_('Serial Number')
      )
      asset_tag = forms.CharField(
          label=_('Asset tag'),
          max_length=50,
          required=False
      )
      form_factor = forms.ChoiceField(
          label=_('Form factor'),
          choices=add_blank_choice(RackFormFactorChoices),
          required=False
      )
      width = forms.ChoiceField(
          label=_('Width'),
          choices=add_blank_choice(RackWidthChoices),
          required=False
      )
      u_height = forms.IntegerField(
          required=False,
          label=_('Height (U)')
      )
      desc_units = forms.NullBooleanField(
          required=False,
          widget=BulkEditNullBooleanSelect,
          label=_('Descending units')
      )
      outer_width = forms.IntegerField(
          label=_('Outer width'),
          required=False,
          min_value=1
      )
      outer_height = forms.IntegerField(
          label=_('Outer height'),
          required=False,
          min_value=1
      )
      outer_depth = forms.IntegerField(
          label=_('Outer depth'),
          required=False,
          min_value=1
      )
      outer_unit = forms.ChoiceField(
          label=_('Outer unit'),
          choices=add_blank_choice(RackDimensionUnitChoices),
          required=False
      )
      mounting_depth = forms.IntegerField(
          label=_('Mounting depth'),
          required=False,
          min_value=1
      )
      airflow = forms.ChoiceField(
          label=_('Airflow'),
          choices=add_blank_choice(RackAirflowChoices),
          required=False
      )
      weight = forms.DecimalField(
          label=_('Weight'),
          min_value=0,
          required=False
      )
      max_weight = forms.IntegerField(
          label=_('Max weight'),
          min_value=0,
          required=False
      )
      weight_unit = forms.ChoiceField(
          label=_('Weight unit'),
          choices=add_blank_choice(WeightUnitChoices),
          required=False,
          initial=''
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Rack
      fieldsets = (
          FieldSet('status', 'role', 'tenant', 'serial', 'asset_tag', 'rack_type', 'description', name=_('Rack')),
          FieldSet('region', 'site_group', 'site', 'location', name=_('Location')),
          FieldSet('outer_width', 'outer_height', 'outer_depth', 'outer_unit', name=_('Outer Dimensions')),
          FieldSet('form_factor', 'width', 'u_height', 'desc_units', 'airflow', 'mounting_depth', name=_('Hardware')),
          FieldSet('weight', 'max_weight', 'weight_unit', name=_('Weight')),
      )
      nullable_fields = (
          'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_height', 'outer_depth',
          'outer_unit', 'weight', 'max_weight', 'weight_unit', 'description', 'comments',
      )
  
  
  class RackReservationBulkEditForm(NetBoxModelBulkEditForm):
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(RackReservationStatusChoices),
          required=False,
          initial=''
      )
      user = forms.ModelChoiceField(
          label=_('User'),
          queryset=User.objects.order_by('username'),
          required=False
      )
      tenant = DynamicModelChoiceField(
          label=_('Tenant'),
          queryset=Tenant.objects.all(),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = RackReservation
      fieldsets = (
          FieldSet('status', 'user', 'tenant', 'description'),
      )
      nullable_fields = ('comments',)
  
  
  class ManufacturerBulkEditForm(NetBoxModelBulkEditForm):
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
  
      model = Manufacturer
      fieldsets = (
          FieldSet('description'),
      )
      nullable_fields = ('description',)
  
  
  class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
      manufacturer = DynamicModelChoiceField(
          label=_('Manufacturer'),
          queryset=Manufacturer.objects.all(),
          required=False
      )
      default_platform = DynamicModelChoiceField(
          label=_('Default platform'),
          queryset=Platform.objects.all(),
          required=False
      )
      part_number = forms.CharField(
          label=_('Part number'),
          required=False
      )
      u_height = forms.IntegerField(
          label=_('U height'),
          min_value=0,
          required=False
      )
      is_full_depth = forms.NullBooleanField(
          required=False,
          widget=BulkEditNullBooleanSelect(),
          label=_('Is full depth')
      )
      exclude_from_utilization = forms.NullBooleanField(
          required=False,
          widget=BulkEditNullBooleanSelect(),
          label=_('Exclude from utilization')
      )
      airflow = forms.ChoiceField(
          label=_('Airflow'),
          choices=add_blank_choice(DeviceAirflowChoices),
          required=False
      )
      weight = forms.DecimalField(
          label=_('Weight'),
          min_value=0,
          required=False
      )
      weight_unit = forms.ChoiceField(
          label=_('Weight unit'),
          choices=add_blank_choice(WeightUnitChoices),
          required=False,
          initial=''
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = DeviceType
      fieldsets = (
          FieldSet(
              'manufacturer', 'default_platform', 'part_number', 'u_height', 'exclude_from_utilization', 'is_full_depth',
              'airflow', 'description', name=_('Device Type')
          ),
          FieldSet('weight', 'weight_unit', name=_('Weight')),
      )
      nullable_fields = ('part_number', 'airflow', 'weight', 'weight_unit', 'description', 'comments')
  
  
  class ModuleTypeProfileBulkEditForm(NetBoxModelBulkEditForm):
      schema = JSONField(
          label=_('Schema'),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = ModuleTypeProfile
      fieldsets = (
          FieldSet('name', 'description', 'schema', name=_('Profile')),
      )
      nullable_fields = ('description', 'comments')
  
  
  class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm):
      profile = DynamicModelChoiceField(
          label=_('Profile'),
          queryset=ModuleTypeProfile.objects.all(),
          required=False
      )
      manufacturer = DynamicModelChoiceField(
          label=_('Manufacturer'),
          queryset=Manufacturer.objects.all(),
          required=False
      )
      part_number = forms.CharField(
          label=_('Part number'),
          required=False
      )
      airflow = forms.ChoiceField(
          label=_('Airflow'),
          choices=add_blank_choice(ModuleAirflowChoices),
          required=False
      )
      weight = forms.DecimalField(
          label=_('Weight'),
          min_value=0,
          required=False
      )
      weight_unit = forms.ChoiceField(
          label=_('Weight unit'),
          choices=add_blank_choice(WeightUnitChoices),
          required=False,
          initial=''
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = ModuleType
      fieldsets = (
          FieldSet('profile', 'manufacturer', 'part_number', 'description', name=_('Module Type')),
          FieldSet(
              'airflow',
              InlineFields('weight', 'max_weight', 'weight_unit', label=_('Weight')),
              name=_('Chassis')
          ),
      )
      nullable_fields = ('part_number', 'weight', 'weight_unit', 'profile', 'description', 'comments')
  
  
  class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm):
      parent = DynamicModelChoiceField(
          label=_('Parent'),
          queryset=DeviceRole.objects.all(),
          required=False,
      )
      color = ColorField(
          label=_('Color'),
          required=False
      )
      vm_role = forms.NullBooleanField(
          required=False,
          widget=BulkEditNullBooleanSelect,
          label=_('VM role')
      )
      config_template = DynamicModelChoiceField(
          label=_('Config template'),
          queryset=ConfigTemplate.objects.all(),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = DeviceRole
      fieldsets = (
          FieldSet('parent', 'color', 'vm_role', 'config_template', 'description'),
      )
      nullable_fields = ('parent', 'color', 'config_template', 'description', 'comments')
  
  
  class PlatformBulkEditForm(NetBoxModelBulkEditForm):
      parent = DynamicModelChoiceField(
          label=_('Parent'),
          queryset=Platform.objects.all(),
          required=False,
      )
      manufacturer = DynamicModelChoiceField(
          label=_('Manufacturer'),
          queryset=Manufacturer.objects.all(),
          required=False
      )
      config_template = DynamicModelChoiceField(
          label=_('Config template'),
          queryset=ConfigTemplate.objects.all(),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Platform
      fieldsets = (
          FieldSet('parent', 'manufacturer', 'config_template', 'description'),
      )
      nullable_fields = ('parent', 'manufacturer', 'config_template', 'description', 'comments')
  
  
  class DeviceBulkEditForm(NetBoxModelBulkEditForm):
      manufacturer = DynamicModelChoiceField(
          label=_('Manufacturer'),
          queryset=Manufacturer.objects.all(),
          required=False
      )
      device_type = DynamicModelChoiceField(
          label=_('Device type'),
          queryset=DeviceType.objects.all(),
          required=False,
          context={
              'parent': 'manufacturer',
          },
          query_params={
              'manufacturer_id': '$manufacturer'
          }
      )
      role = DynamicModelChoiceField(
          label=_('Device role'),
          queryset=DeviceRole.objects.all(),
          required=False
      )
      site = DynamicModelChoiceField(
          label=_('Site'),
          queryset=Site.objects.all(),
          required=False
      )
      location = DynamicModelChoiceField(
          label=_('Location'),
          queryset=Location.objects.all(),
          required=False,
          query_params={
              'site_id': '$site'
          }
      )
      tenant = DynamicModelChoiceField(
          label=_('Tenant'),
          queryset=Tenant.objects.all(),
          required=False
      )
      platform = DynamicModelChoiceField(
          label=_('Platform'),
          queryset=Platform.objects.all(),
          required=False
      )
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(DeviceStatusChoices),
          required=False
      )
      airflow = forms.ChoiceField(
          label=_('Airflow'),
          choices=add_blank_choice(DeviceAirflowChoices),
          required=False
      )
      serial = forms.CharField(
          max_length=50,
          required=False,
          label=_('Serial Number')
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      config_template = DynamicModelChoiceField(
          label=_('Config template'),
          queryset=ConfigTemplate.objects.all(),
          required=False
      )
      cluster = DynamicModelChoiceField(
          label=_('Cluster'),
          queryset=Cluster.objects.all(),
          required=False,
          query_params={
              'site_id': ['$site', 'null']
          },
      )
      comments = CommentField()
  
      model = Device
      fieldsets = (
          FieldSet('role', 'status', 'tenant', 'platform', 'description', name=_('Device')),
          FieldSet('site', 'location', name=_('Location')),
          FieldSet('manufacturer', 'device_type', 'airflow', 'serial', name=_('Hardware')),
          FieldSet('config_template', name=_('Configuration')),
          FieldSet('cluster', name=_('Virtualization')),
      )
      nullable_fields = (
          'location', 'tenant', 'platform', 'serial', 'airflow', 'description', 'cluster', 'comments',
      )
  
  
  class ModuleBulkEditForm(NetBoxModelBulkEditForm):
      manufacturer = DynamicModelChoiceField(
          label=_('Manufacturer'),
          queryset=Manufacturer.objects.all(),
          required=False
      )
      module_type = DynamicModelChoiceField(
          label=_('Module type'),
          queryset=ModuleType.objects.all(),
          required=False,
          query_params={
              'manufacturer_id': '$manufacturer'
          },
          context={
              'parent': 'manufacturer',
          }
      )
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(ModuleStatusChoices),
          required=False,
          initial=''
      )
      serial = forms.CharField(
          max_length=50,
          required=False,
          label=_('Serial Number')
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Module
      fieldsets = (
          FieldSet('manufacturer', 'module_type', 'status', 'serial', 'description'),
      )
      nullable_fields = ('serial', 'description', 'comments')
  
  
  class CableBulkEditForm(NetBoxModelBulkEditForm):
      type = forms.ChoiceField(
          label=_('Type'),
          choices=add_blank_choice(CableTypeChoices),
          required=False,
          initial=''
      )
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(LinkStatusChoices),
          required=False,
          initial=''
      )
      tenant = DynamicModelChoiceField(
          label=_('Tenant'),
          queryset=Tenant.objects.all(),
          required=False
      )
      label = forms.CharField(
          label=_('Label'),
          max_length=100,
          required=False
      )
      color = ColorField(
          label=_('Color'),
          required=False
      )
      length = forms.DecimalField(
          label=_('Length'),
          min_value=0,
          required=False
      )
      length_unit = forms.ChoiceField(
          label=_('Length unit'),
          choices=add_blank_choice(CableLengthUnitChoices),
          required=False,
          initial=''
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = Cable
      fieldsets = (
          FieldSet('type', 'status', 'tenant', 'label', 'description'),
          FieldSet('color', 'length', 'length_unit', name=_('Attributes')),
      )
      nullable_fields = (
          'type', 'status', 'tenant', 'label', 'color', 'length', 'description', 'comments',
      )
  
  
  class VirtualChassisBulkEditForm(NetBoxModelBulkEditForm):
      domain = forms.CharField(
          label=_('Domain'),
          max_length=30,
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = VirtualChassis
      fieldsets = (
          FieldSet('domain', 'description'),
      )
      nullable_fields = ('domain', 'description', 'comments')
  
  
  class PowerPanelBulkEditForm(NetBoxModelBulkEditForm):
      region = DynamicModelChoiceField(
          label=_('Region'),
          queryset=Region.objects.all(),
          required=False,
          initial_params={
              'sites': '$site'
          }
      )
      site_group = DynamicModelChoiceField(
          label=_('Site group'),
          queryset=SiteGroup.objects.all(),
          required=False,
          initial_params={
              'sites': '$site'
          }
      )
      site = DynamicModelChoiceField(
          label=_('Site'),
          queryset=Site.objects.all(),
          required=False,
          query_params={
              'region_id': '$region',
              'group_id': '$site_group',
          }
      )
      location = DynamicModelChoiceField(
          label=_('Location'),
          queryset=Location.objects.all(),
          required=False,
          query_params={
              'site_id': '$site'
          }
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = PowerPanel
      fieldsets = (
          FieldSet('region', 'site_group', 'site', 'location', 'description'),
      )
      nullable_fields = ('location', 'description', 'comments')
  
  
  class PowerFeedBulkEditForm(NetBoxModelBulkEditForm):
      power_panel = DynamicModelChoiceField(
          label=_('Power panel'),
          queryset=PowerPanel.objects.all(),
          required=False
      )
      rack = DynamicModelChoiceField(
          label=_('Rack'),
          queryset=Rack.objects.all(),
          required=False,
      )
      status = forms.ChoiceField(
          label=_('Status'),
          choices=add_blank_choice(PowerFeedStatusChoices),
          required=False,
          initial=''
      )
      type = forms.ChoiceField(
          label=_('Type'),
          choices=add_blank_choice(PowerFeedTypeChoices),
          required=False,
          initial=''
      )
      supply = forms.ChoiceField(
          label=_('Supply'),
          choices=add_blank_choice(PowerFeedSupplyChoices),
          required=False,
          initial=''
      )
      phase = forms.ChoiceField(
          label=_('Phase'),
          choices=add_blank_choice(PowerFeedPhaseChoices),
          required=False,
          initial=''
      )
      voltage = forms.IntegerField(
          label=_('Voltage'),
          required=False
      )
      amperage = forms.IntegerField(
          label=_('Amperage'),
          required=False
      )
      max_utilization = forms.IntegerField(
          label=_('Max utilization'),
          required=False
      )
      mark_connected = forms.NullBooleanField(
          label=_('Mark connected'),
          required=False,
          widget=BulkEditNullBooleanSelect
      )
      tenant = DynamicModelChoiceField(
          queryset=Tenant.objects.all(),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          max_length=200,
          required=False
      )
      comments = CommentField()
  
      model = PowerFeed
      fieldsets = (
          FieldSet('power_panel', 'rack', 'status', 'type', 'mark_connected', 'description', 'tenant'),
          FieldSet('supply', 'phase', 'voltage', 'amperage', 'max_utilization', name=_('Power'))
      )
      nullable_fields = ('location', 'tenant', 'description', 'comments')
  
  
  #
  # Device component templates
  #
  
  class ComponentTemplateBulkEditForm(ChangelogMessageMixin, BulkEditForm):
      pass
  
  
  class ConsolePortTemplateBulkEditForm(ComponentTemplateBulkEditForm):
      pk = forms.ModelMultipleChoiceField(
          queryset=ConsolePortTemplate.objects.all(),
          widget=forms.MultipleHiddenInput()
      )
      label = forms.CharField(
          label=_('Label'),
          max_length=64,
          required=False
      )
      type = forms.ChoiceField(
          label=_('Type'),
          choices=add_blank_choice(ConsolePortTypeChoices),
          required=False
      )
  
      nullable_fields = ('label', 'type', 'description')
  
  
  class ConsoleServerPortTemplateBulkEditForm(ComponentTemplateBulkEditForm):
      pk = forms.ModelMultipleChoiceField(
          queryset=ConsoleServerPortTemplate.objects.all(),
          widget=forms.MultipleHiddenInput()
      )
      label = forms.CharField(
          label=_('Label'),
          max_length=64,
          required=False
      )
      type = forms.ChoiceField(
          label=_('Type'),
          choices=add_blank_choice(ConsolePortTypeChoices),
          required=False
      )
      description = forms.CharField(
          label=_('Description'),
          required=False
      )
  
      nullable_fields = ('label', 'type', 'description')
  
  
  class PowerPortTemplateBulkEditForm(ComponentTemplateBulkEditForm):
      pk = forms.ModelMultipleChoiceField(
          queryset=PowerPortTemplate.objects.all(),
          widget=forms.MultipleHiddenInput()
      )
      label = forms.CharField(
          label=_('Label'),
          max_length=64,
          required=False
      )
      type = forms.ChoiceField(
          label=_('Type'),
          choices=add_blank_choice(PowerPortTypeChoices),
          required=False
      )
      maximum_draw = forms.IntegerField(
          label=_('Maximum draw'),
          min_value=1,
          required=False,
          help_text=_("Maximum power draw (watts)")
      )
      allocated_draw = forms.IntegerField(
          label=_('Allocated draw'),
          min_value=1,
          required=False,
          help_text=_("Allocated power draw (watts)")
      )
      description = forms.CharField(
          label=_('Description'),
          required=False
      )
  
      nullable_fields = ('label', 'type', 'maximum_draw', 'allocated_draw', 'description')
  
  
  class PowerOutletTemplateBulkEditForm(ComponentTemplateBulkEditForm):
      pk = forms.ModelMultipleChoiceField(
          queryset=PowerOutletTemplate.objects.all(),
          widget=forms.MultipleHiddenInput()
      )
      device_type = forms.ModelChoiceField(
          label=_('Device type'),
          queryset=DeviceType.objects.all(),
          required=False,
          disabled=True,
          widget=forms.HiddenInput()
      )
      label = forms.CharField(
          label=_('Label'),
          max_length=64,
          required=False
      )
      type = forms.ChoiceField(
          label=_('Type'),
          choices=add_blank_choice(PowerOutletTypeChoices),
          required=False
      )
      power_port = forms.ModelChoiceField(
          label=_('Power port'),
          queryset=PowerPortTemplate.objects.all(),
          required=False
      )
      feed_leg = forms.ChoiceField(
          label=_('Feed leg'),
          choices=add_blank_choice(PowerOutletFeedLegChoices),
          required=False
      )
  