mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
Define default label for SlugField
This commit is contained in:
parent
406cee91cc
commit
d7d7353784
@ -60,9 +60,7 @@ class ProviderNetworkImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class CircuitTypeImportForm(NetBoxModelImportForm):
|
class CircuitTypeImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = CircuitType
|
model = CircuitType
|
||||||
|
@ -78,9 +78,7 @@ class ProviderNetworkForm(NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class CircuitTypeForm(NetBoxModelForm):
|
class CircuitTypeForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Circuit Type'), (
|
(_('Circuit Type'), (
|
||||||
|
@ -159,9 +159,7 @@ class LocationImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class RackRoleImportForm(NetBoxModelImportForm):
|
class RackRoleImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RackRole
|
model = RackRole
|
||||||
@ -382,9 +380,7 @@ class DeviceRoleImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class PlatformImportForm(NetBoxModelImportForm):
|
class PlatformImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
manufacturer = CSVModelChoiceField(
|
manufacturer = CSVModelChoiceField(
|
||||||
label=_('Manufacturer'),
|
label=_('Manufacturer'),
|
||||||
queryset=Manufacturer.objects.all(),
|
queryset=Manufacturer.objects.all(),
|
||||||
@ -1083,9 +1079,7 @@ class InventoryItemImportForm(NetBoxModelImportForm):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class InventoryItemRoleImportForm(NetBoxModelImportForm):
|
class InventoryItemRoleImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = InventoryItemRole
|
model = InventoryItemRole
|
||||||
|
@ -74,9 +74,7 @@ class RegionForm(NetBoxModelForm):
|
|||||||
queryset=Region.objects.all(),
|
queryset=Region.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Region'), (
|
(_('Region'), (
|
||||||
@ -97,9 +95,7 @@ class SiteGroupForm(NetBoxModelForm):
|
|||||||
queryset=SiteGroup.objects.all(),
|
queryset=SiteGroup.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Site Group'), (
|
(_('Site Group'), (
|
||||||
@ -130,9 +126,7 @@ class SiteForm(TenancyForm, NetBoxModelForm):
|
|||||||
label=_('ASNs'),
|
label=_('ASNs'),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
time_zone = TimeZoneFormField(
|
time_zone = TimeZoneFormField(
|
||||||
label=_('Time zone'),
|
label=_('Time zone'),
|
||||||
choices=add_blank_choice(TimeZoneFormField().choices),
|
choices=add_blank_choice(TimeZoneFormField().choices),
|
||||||
@ -199,9 +193,7 @@ class LocationForm(TenancyForm, NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class RackRoleForm(NetBoxModelForm):
|
class RackRoleForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Rack Role'), (
|
(_('Rack Role'), (
|
||||||
@ -280,9 +272,7 @@ class RackReservationForm(TenancyForm, NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class ManufacturerForm(NetBoxModelForm):
|
class ManufacturerForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Manufacturer'), (
|
(_('Manufacturer'), (
|
||||||
@ -367,9 +357,7 @@ class DeviceRoleForm(NetBoxModelForm):
|
|||||||
queryset=ConfigTemplate.objects.all(),
|
queryset=ConfigTemplate.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Device Role'), (
|
(_('Device Role'), (
|
||||||
@ -1459,9 +1447,7 @@ class InventoryItemForm(DeviceComponentForm):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class InventoryItemRoleForm(NetBoxModelForm):
|
class InventoryItemRoleForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Inventory Item Role'), (
|
(_('Inventory Item Role'), (
|
||||||
|
@ -158,9 +158,7 @@ class WebhookImportForm(CSVModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class TagImportForm(CSVModelForm):
|
class TagImportForm(CSVModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Tag
|
model = Tag
|
||||||
|
@ -63,9 +63,7 @@ class RouteTargetImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class RIRImportForm(NetBoxModelImportForm):
|
class RIRImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RIR
|
model = RIR
|
||||||
@ -133,9 +131,7 @@ class ASNImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class RoleImportForm(NetBoxModelImportForm):
|
class RoleImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
@ -396,9 +392,7 @@ class FHRPGroupImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class VLANGroupImportForm(NetBoxModelImportForm):
|
class VLANGroupImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
scope_type = CSVContentTypeField(
|
scope_type = CSVContentTypeField(
|
||||||
queryset=ContentType.objects.filter(model__in=VLANGROUP_SCOPE_TYPES),
|
queryset=ContentType.objects.filter(model__in=VLANGROUP_SCOPE_TYPES),
|
||||||
required=False,
|
required=False,
|
||||||
|
@ -93,9 +93,7 @@ class RouteTargetForm(TenancyForm, NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class RIRForm(NetBoxModelForm):
|
class RIRForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('RIR'), (
|
(_('RIR'), (
|
||||||
@ -139,9 +137,7 @@ class ASNRangeForm(TenancyForm, NetBoxModelForm):
|
|||||||
queryset=RIR.objects.all(),
|
queryset=RIR.objects.all(),
|
||||||
label=_('RIR'),
|
label=_('RIR'),
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('ASN Range'), ('name', 'slug', 'rir', 'start', 'end', 'description', 'tags')),
|
(_('ASN Range'), ('name', 'slug', 'rir', 'start', 'end', 'description', 'tags')),
|
||||||
(_('Tenancy'), ('tenant_group', 'tenant')),
|
(_('Tenancy'), ('tenant_group', 'tenant')),
|
||||||
@ -605,9 +601,7 @@ class VLANGroupForm(NetBoxModelForm):
|
|||||||
'group_id': '$clustergroup',
|
'group_id': '$clustergroup',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('VLAN Group'), ('name', 'slug', 'description', 'tags')),
|
(_('VLAN Group'), ('name', 'slug', 'description', 'tags')),
|
||||||
@ -777,9 +771,7 @@ class ServiceCreateForm(ServiceForm):
|
|||||||
|
|
||||||
|
|
||||||
class L2VPNForm(TenancyForm, NetBoxModelForm):
|
class L2VPNForm(TenancyForm, NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
import_targets = DynamicModelMultipleChoiceField(
|
import_targets = DynamicModelMultipleChoiceField(
|
||||||
label=_('Import targets'),
|
label=_('Import targets'),
|
||||||
queryset=RouteTarget.objects.all(),
|
queryset=RouteTarget.objects.all(),
|
||||||
|
@ -27,9 +27,7 @@ class TenantGroupImportForm(NetBoxModelImportForm):
|
|||||||
to_field_name='name',
|
to_field_name='name',
|
||||||
help_text=_('Parent group')
|
help_text=_('Parent group')
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TenantGroup
|
model = TenantGroup
|
||||||
@ -37,9 +35,7 @@ class TenantGroupImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class TenantImportForm(NetBoxModelImportForm):
|
class TenantImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
group = CSVModelChoiceField(
|
group = CSVModelChoiceField(
|
||||||
label=_('Group'),
|
label=_('Group'),
|
||||||
queryset=TenantGroup.objects.all(),
|
queryset=TenantGroup.objects.all(),
|
||||||
@ -65,9 +61,7 @@ class ContactGroupImportForm(NetBoxModelImportForm):
|
|||||||
to_field_name='name',
|
to_field_name='name',
|
||||||
help_text=_('Parent group')
|
help_text=_('Parent group')
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ContactGroup
|
model = ContactGroup
|
||||||
@ -75,9 +69,7 @@ class ContactGroupImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class ContactRoleImportForm(NetBoxModelImportForm):
|
class ContactRoleImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ContactRole
|
model = ContactRole
|
||||||
|
@ -26,9 +26,7 @@ class TenantGroupForm(NetBoxModelForm):
|
|||||||
queryset=TenantGroup.objects.all(),
|
queryset=TenantGroup.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Tenant Group'), (
|
(_('Tenant Group'), (
|
||||||
@ -44,9 +42,7 @@ class TenantGroupForm(NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class TenantForm(NetBoxModelForm):
|
class TenantForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
group = DynamicModelChoiceField(
|
group = DynamicModelChoiceField(
|
||||||
label=_('Group'),
|
label=_('Group'),
|
||||||
queryset=TenantGroup.objects.all(),
|
queryset=TenantGroup.objects.all(),
|
||||||
@ -77,9 +73,7 @@ class ContactGroupForm(NetBoxModelForm):
|
|||||||
queryset=ContactGroup.objects.all(),
|
queryset=ContactGroup.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Contact Group'), (
|
(_('Contact Group'), (
|
||||||
@ -93,9 +87,7 @@ class ContactGroupForm(NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class ContactRoleForm(NetBoxModelForm):
|
class ContactRoleForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Contact Role'), (
|
(_('Contact Role'), (
|
||||||
|
@ -44,10 +44,11 @@ class SlugField(forms.SlugField):
|
|||||||
slug_source: Name of the form field from which the slug value will be derived
|
slug_source: Name of the form field from which the slug value will be derived
|
||||||
"""
|
"""
|
||||||
widget = widgets.SlugWidget
|
widget = widgets.SlugWidget
|
||||||
|
label = _('Slug')
|
||||||
help_text = _("URL-friendly unique shorthand")
|
help_text = _("URL-friendly unique shorthand")
|
||||||
|
|
||||||
def __init__(self, *, slug_source='name', help_text=help_text, **kwargs):
|
def __init__(self, *, slug_source='name', label=label, help_text=help_text, **kwargs):
|
||||||
super().__init__(help_text=help_text, **kwargs)
|
super().__init__(label=label, help_text=help_text, **kwargs)
|
||||||
|
|
||||||
self.widget.attrs['slug-source'] = slug_source
|
self.widget.attrs['slug-source'] = slug_source
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ __all__ = (
|
|||||||
|
|
||||||
|
|
||||||
class ClusterTypeImportForm(NetBoxModelImportForm):
|
class ClusterTypeImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ClusterType
|
model = ClusterType
|
||||||
@ -29,9 +27,7 @@ class ClusterTypeImportForm(NetBoxModelImportForm):
|
|||||||
|
|
||||||
|
|
||||||
class ClusterGroupImportForm(NetBoxModelImportForm):
|
class ClusterGroupImportForm(NetBoxModelImportForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ClusterGroup
|
model = ClusterGroup
|
||||||
|
@ -27,9 +27,7 @@ __all__ = (
|
|||||||
|
|
||||||
|
|
||||||
class ClusterTypeForm(NetBoxModelForm):
|
class ClusterTypeForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Cluster Type'), (
|
(_('Cluster Type'), (
|
||||||
@ -45,9 +43,7 @@ class ClusterTypeForm(NetBoxModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class ClusterGroupForm(NetBoxModelForm):
|
class ClusterGroupForm(NetBoxModelForm):
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Cluster Group'), (
|
(_('Cluster Group'), (
|
||||||
|
@ -24,9 +24,7 @@ class WirelessLANGroupImportForm(NetBoxModelImportForm):
|
|||||||
to_field_name='name',
|
to_field_name='name',
|
||||||
help_text=_('Parent group')
|
help_text=_('Parent group')
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = WirelessLANGroup
|
model = WirelessLANGroup
|
||||||
|
@ -21,9 +21,7 @@ class WirelessLANGroupForm(NetBoxModelForm):
|
|||||||
queryset=WirelessLANGroup.objects.all(),
|
queryset=WirelessLANGroup.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
slug = SlugField(
|
slug = SlugField()
|
||||||
label=_('Slug'),
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Wireless LAN Group'), (
|
(_('Wireless LAN Group'), (
|
||||||
|
Loading…
Reference in New Issue
Block a user