1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Move nullable_fields out of Meta for bulk edit forms

This commit is contained in:
jeremystretch
2022-01-31 16:15:40 -05:00
parent 353e132cf9
commit d1672f8818
8 changed files with 110 additions and 199 deletions

View File

@ -47,10 +47,9 @@ class ProviderBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'comments',
)
nullable_fields = (
'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'comments',
)
class ProviderNetworkBulkEditForm(NetBoxModelBulkEditForm):
@ -75,10 +74,9 @@ class ProviderNetworkBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'service_id', 'description', 'comments',
)
nullable_fields = (
'service_id', 'description', 'comments',
)
class CircuitTypeBulkEditForm(NetBoxModelBulkEditForm):
@ -91,8 +89,7 @@ class CircuitTypeBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class CircuitBulkEditForm(NetBoxModelBulkEditForm):
@ -131,7 +128,6 @@ class CircuitBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'tenant', 'commit_rate', 'description', 'comments',
)
nullable_fields = (
'tenant', 'commit_rate', 'description', 'comments',
)

View File

@ -71,8 +71,7 @@ class RegionBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('parent', 'description')
nullable_fields = ('parent', 'description')
class SiteGroupBulkEditForm(NetBoxModelBulkEditForm):
@ -89,8 +88,7 @@ class SiteGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('parent', 'description')
nullable_fields = ('parent', 'description')
class SiteBulkEditForm(NetBoxModelBulkEditForm):
@ -131,10 +129,9 @@ class SiteBulkEditForm(NetBoxModelBulkEditForm):
widget=StaticSelect()
)
class Meta:
nullable_fields = (
'region', 'group', 'tenant', 'asns', 'description', 'time_zone',
)
nullable_fields = (
'region', 'group', 'tenant', 'asns', 'description', 'time_zone',
)
class LocationBulkEditForm(NetBoxModelBulkEditForm):
@ -162,8 +159,7 @@ class LocationBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('parent', 'tenant', 'description')
nullable_fields = ('parent', 'tenant', 'description')
class RackRoleBulkEditForm(NetBoxModelBulkEditForm):
@ -179,8 +175,7 @@ class RackRoleBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('color', 'description')
nullable_fields = ('color', 'description')
class RackBulkEditForm(NetBoxModelBulkEditForm):
@ -277,10 +272,9 @@ class RackBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'comments',
)
nullable_fields = (
'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'comments',
)
class RackReservationBulkEditForm(NetBoxModelBulkEditForm):
@ -315,8 +309,7 @@ class ManufacturerBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
@ -346,8 +339,7 @@ class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
widget=StaticSelect()
)
class Meta:
nullable_fields = ('part_number', 'airflow')
nullable_fields = ('part_number', 'airflow')
class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm):
@ -363,8 +355,7 @@ class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('part_number',)
nullable_fields = ('part_number',)
class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm):
@ -385,8 +376,7 @@ class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('color', 'description')
nullable_fields = ('color', 'description')
class PlatformBulkEditForm(NetBoxModelBulkEditForm):
@ -408,8 +398,7 @@ class PlatformBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('manufacturer', 'napalm_driver', 'description')
nullable_fields = ('manufacturer', 'napalm_driver', 'description')
class DeviceBulkEditForm(NetBoxModelBulkEditForm):
@ -467,10 +456,9 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm):
label='Serial Number'
)
class Meta:
nullable_fields = (
'tenant', 'platform', 'serial', 'airflow',
)
nullable_fields = (
'tenant', 'platform', 'serial', 'airflow',
)
class ModuleBulkEditForm(NetBoxModelBulkEditForm):
@ -495,8 +483,7 @@ class ModuleBulkEditForm(NetBoxModelBulkEditForm):
label='Serial Number'
)
class Meta:
nullable_fields = ('serial',)
nullable_fields = ('serial',)
class CableBulkEditForm(NetBoxModelBulkEditForm):
@ -538,10 +525,9 @@ class CableBulkEditForm(NetBoxModelBulkEditForm):
widget=StaticSelect()
)
class Meta:
nullable_fields = (
'type', 'status', 'tenant', 'label', 'color', 'length',
)
nullable_fields = (
'type', 'status', 'tenant', 'label', 'color', 'length',
)
def clean(self):
super().clean()
@ -565,8 +551,7 @@ class VirtualChassisBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('domain',)
nullable_fields = ('domain',)
class PowerPanelBulkEditForm(NetBoxModelBulkEditForm):
@ -604,8 +589,7 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm):
}
)
class Meta:
nullable_fields = ('location',)
nullable_fields = ('location',)
class PowerFeedBulkEditForm(NetBoxModelBulkEditForm):
@ -663,10 +647,7 @@ class PowerFeedBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'location', 'comments',
)
nullable_fields = ('location', 'comments')
#
@ -688,8 +669,7 @@ class ConsolePortTemplateBulkEditForm(BulkEditForm):
widget=StaticSelect()
)
class Meta:
nullable_fields = ('label', 'type', 'description')
nullable_fields = ('label', 'type', 'description')
class ConsoleServerPortTemplateBulkEditForm(BulkEditForm):
@ -710,8 +690,7 @@ class ConsoleServerPortTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'type', 'description')
nullable_fields = ('label', 'type', 'description')
class PowerPortTemplateBulkEditForm(BulkEditForm):
@ -742,8 +721,7 @@ class PowerPortTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'type', 'maximum_draw', 'allocated_draw', 'description')
nullable_fields = ('label', 'type', 'maximum_draw', 'allocated_draw', 'description')
class PowerOutletTemplateBulkEditForm(BulkEditForm):
@ -779,8 +757,7 @@ class PowerOutletTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'type', 'power_port', 'feed_leg', 'description')
nullable_fields = ('label', 'type', 'power_port', 'feed_leg', 'description')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -817,8 +794,7 @@ class InterfaceTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class FrontPortTemplateBulkEditForm(BulkEditForm):
@ -842,8 +818,7 @@ class FrontPortTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class RearPortTemplateBulkEditForm(BulkEditForm):
@ -867,8 +842,7 @@ class RearPortTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class ModuleBayTemplateBulkEditForm(BulkEditForm):
@ -884,8 +858,7 @@ class ModuleBayTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'position', 'description')
nullable_fields = ('label', 'position', 'description')
class DeviceBayTemplateBulkEditForm(BulkEditForm):
@ -901,8 +874,7 @@ class DeviceBayTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class InventoryItemTemplateBulkEditForm(BulkEditForm):
@ -926,8 +898,7 @@ class InventoryItemTemplateBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('label', 'role', 'manufacturer', 'part_id', 'description')
nullable_fields = ('label', 'role', 'manufacturer', 'part_id', 'description')
#
@ -947,8 +918,7 @@ class ConsolePortBulkEditForm(
widget=BulkEditNullBooleanSelect
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class ConsoleServerPortBulkEditForm(
@ -964,8 +934,7 @@ class ConsoleServerPortBulkEditForm(
widget=BulkEditNullBooleanSelect
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class PowerPortBulkEditForm(
@ -981,8 +950,7 @@ class PowerPortBulkEditForm(
widget=BulkEditNullBooleanSelect
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class PowerOutletBulkEditForm(
@ -1004,8 +972,7 @@ class PowerOutletBulkEditForm(
widget=BulkEditNullBooleanSelect
)
class Meta:
nullable_fields = ('label', 'type', 'feed_leg', 'power_port', 'description')
nullable_fields = ('label', 'type', 'feed_leg', 'power_port', 'description')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -1084,12 +1051,10 @@ class InterfaceBulkEditForm(
label='VRF'
)
class Meta:
nullable_fields = (
'label', 'parent', 'bridge', 'lag', 'speed', 'duplex', 'mac_address', 'wwn', 'mtu', 'description', 'mode',
'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'untagged_vlan', 'tagged_vlans',
'vrf',
)
nullable_fields = (
'label', 'parent', 'bridge', 'lag', 'speed', 'duplex', 'mac_address', 'wwn', 'mtu', 'description', 'mode',
'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'untagged_vlan', 'tagged_vlans', 'vrf',
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -1154,8 +1119,7 @@ class FrontPortBulkEditForm(
widget=forms.MultipleHiddenInput()
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class RearPortBulkEditForm(
@ -1167,8 +1131,7 @@ class RearPortBulkEditForm(
widget=forms.MultipleHiddenInput()
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class ModuleBayBulkEditForm(
@ -1180,8 +1143,7 @@ class ModuleBayBulkEditForm(
widget=forms.MultipleHiddenInput()
)
class Meta:
nullable_fields = ('label', 'position', 'description')
nullable_fields = ('label', 'position', 'description')
class DeviceBayBulkEditForm(
@ -1193,8 +1155,7 @@ class DeviceBayBulkEditForm(
widget=forms.MultipleHiddenInput()
)
class Meta:
nullable_fields = ('label', 'description')
nullable_fields = ('label', 'description')
class InventoryItemBulkEditForm(
@ -1214,8 +1175,7 @@ class InventoryItemBulkEditForm(
required=False
)
class Meta:
nullable_fields = ('label', 'role', 'manufacturer', 'part_id', 'description')
nullable_fields = ('label', 'role', 'manufacturer', 'part_id', 'description')
#
@ -1235,5 +1195,4 @@ class InventoryItemRoleBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('color', 'description')
nullable_fields = ('color', 'description')

View File

@ -33,8 +33,7 @@ class CustomFieldBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class CustomLinkBulkEditForm(BulkEditForm):
@ -92,8 +91,7 @@ class ExportTemplateBulkEditForm(BulkEditForm):
widget=BulkEditNullBooleanSelect()
)
class Meta:
nullable_fields = ('description', 'mime_type', 'file_extension')
nullable_fields = ('description', 'mime_type', 'file_extension')
class WebhookBulkEditForm(BulkEditForm):
@ -135,8 +133,7 @@ class WebhookBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('secret', 'conditions', 'ca_file_path')
nullable_fields = ('secret', 'conditions', 'ca_file_path')
class TagBulkEditForm(BulkEditForm):
@ -152,8 +149,7 @@ class TagBulkEditForm(BulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class ConfigContextBulkEditForm(BulkEditForm):
@ -174,8 +170,7 @@ class ConfigContextBulkEditForm(BulkEditForm):
max_length=100
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class JournalEntryBulkEditForm(BulkEditForm):

View File

@ -49,10 +49,7 @@ class VRFBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'tenant', 'description',
)
nullable_fields = ('tenant', 'description')
class RouteTargetBulkEditForm(NetBoxModelBulkEditForm):
@ -69,10 +66,7 @@ class RouteTargetBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'tenant', 'description',
)
nullable_fields = ('tenant', 'description')
class RIRBulkEditForm(NetBoxModelBulkEditForm):
@ -89,8 +83,7 @@ class RIRBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('is_private', 'description')
nullable_fields = ('is_private', 'description')
class ASNBulkEditForm(NetBoxModelBulkEditForm):
@ -116,13 +109,7 @@ class ASNBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'date_added', 'description',
)
widgets = {
'date_added': DatePicker(),
}
nullable_fields = ('date_added', 'description')
class AggregateBulkEditForm(NetBoxModelBulkEditForm):
@ -147,13 +134,7 @@ class AggregateBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'date_added', 'description',
)
widgets = {
'date_added': DatePicker(),
}
nullable_fields = ('date_added', 'description')
class RoleBulkEditForm(NetBoxModelBulkEditForm):
@ -169,8 +150,7 @@ class RoleBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class PrefixBulkEditForm(NetBoxModelBulkEditForm):
@ -232,10 +212,9 @@ class PrefixBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'site', 'vrf', 'tenant', 'role', 'description',
)
nullable_fields = (
'site', 'vrf', 'tenant', 'role', 'description',
)
class IPRangeBulkEditForm(NetBoxModelBulkEditForm):
@ -266,10 +245,9 @@ class IPRangeBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'vrf', 'tenant', 'role', 'description',
)
nullable_fields = (
'vrf', 'tenant', 'role', 'description',
)
class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
@ -311,10 +289,9 @@ class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'vrf', 'role', 'tenant', 'dns_name', 'description',
)
nullable_fields = (
'vrf', 'role', 'tenant', 'dns_name', 'description',
)
class FHRPGroupBulkEditForm(NetBoxModelBulkEditForm):
@ -348,8 +325,7 @@ class FHRPGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('auth_type', 'auth_key', 'description')
nullable_fields = ('auth_type', 'auth_key', 'description')
class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
@ -378,8 +354,7 @@ class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('site', 'description')
nullable_fields = ('site', 'description')
class VLANBulkEditForm(NetBoxModelBulkEditForm):
@ -428,10 +403,9 @@ class VLANBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'site', 'group', 'tenant', 'role', 'description',
)
nullable_fields = (
'site', 'group', 'tenant', 'role', 'description',
)
class ServiceTemplateBulkEditForm(NetBoxModelBulkEditForm):
@ -456,8 +430,7 @@ class ServiceTemplateBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class ServiceBulkEditForm(ServiceTemplateBulkEditForm):

View File

@ -31,8 +31,7 @@ class TenantGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('parent', 'description')
nullable_fields = ('parent', 'description')
class TenantBulkEditForm(NetBoxModelBulkEditForm):
@ -45,8 +44,7 @@ class TenantBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('group',)
nullable_fields = ('group',)
#
@ -67,8 +65,7 @@ class ContactGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('parent', 'description')
nullable_fields = ('parent', 'description')
class ContactRoleBulkEditForm(NetBoxModelBulkEditForm):
@ -81,8 +78,7 @@ class ContactRoleBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class ContactBulkEditForm(NetBoxModelBulkEditForm):
@ -110,5 +106,4 @@ class ContactBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('group', 'title', 'phone', 'email', 'address', 'comments')
nullable_fields = ('group', 'title', 'phone', 'email', 'address', 'comments')

View File

@ -69,14 +69,11 @@ class BulkEditMixin:
"""
Base form for editing multiple objects in bulk
"""
nullable_fields = ()
def __init__(self, model, *args, **kwargs):
super().__init__(*args, **kwargs)
self.model = model
self.nullable_fields = ()
# Copy any nullable fields defined in Meta
if hasattr(self, 'Meta') and hasattr(self.Meta, 'nullable_fields'):
self.nullable_fields = self.Meta.nullable_fields
#

View File

@ -33,8 +33,7 @@ class ClusterTypeBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class ClusterGroupBulkEditForm(NetBoxModelBulkEditForm):
@ -47,8 +46,7 @@ class ClusterGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('description',)
nullable_fields = ('description',)
class ClusterBulkEditForm(NetBoxModelBulkEditForm):
@ -89,10 +87,9 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'group', 'site', 'comments', 'tenant',
)
nullable_fields = (
'group', 'site', 'comments', 'tenant',
)
class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
@ -144,10 +141,9 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
label='Comments'
)
class Meta:
nullable_fields = (
'role', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'comments',
)
nullable_fields = (
'role', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'comments',
)
class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm):
@ -197,10 +193,9 @@ class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = (
'parent', 'bridge', 'mtu', 'description',
)
nullable_fields = (
'parent', 'bridge', 'mtu', 'description',
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

View File

@ -29,8 +29,7 @@ class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False
)
class Meta:
nullable_fields = ('parent', 'description')
nullable_fields = ('parent', 'description')
class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
@ -68,8 +67,9 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
label='Pre-shared key'
)
class Meta:
nullable_fields = ('ssid', 'group', 'vlan', 'description', 'auth_type', 'auth_cipher', 'auth_psk')
nullable_fields = (
'ssid', 'group', 'vlan', 'description', 'auth_type', 'auth_cipher', 'auth_psk',
)
class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
@ -102,5 +102,6 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
label='Pre-shared key'
)
class Meta:
nullable_fields = ('ssid', 'description', 'auth_type', 'auth_cipher', 'auth_psk')
nullable_fields = (
'ssid', 'description', 'auth_type', 'auth_cipher', 'auth_psk',
)