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