mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 13:08:16 -06:00
Rename option_attrs to context
This commit is contained in:
parent
80b49aa6b2
commit
aec66f77f7
@ -557,7 +557,7 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
label=_('Device type'),
|
label=_('Device type'),
|
||||||
queryset=DeviceType.objects.all(),
|
queryset=DeviceType.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
},
|
},
|
||||||
query_params={
|
query_params={
|
||||||
@ -644,7 +644,7 @@ class ModuleBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
query_params={
|
query_params={
|
||||||
'manufacturer_id': '$manufacturer'
|
'manufacturer_id': '$manufacturer'
|
||||||
},
|
},
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -30,7 +30,7 @@ def get_cable_form(a_type, b_type):
|
|||||||
attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
|
attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
|
||||||
queryset=term_cls.objects.all(),
|
queryset=term_cls.objects.all(),
|
||||||
label=term_cls._meta.verbose_name.title(),
|
label=term_cls._meta.verbose_name.title(),
|
||||||
option_attrs={
|
context={
|
||||||
'disabled': '_occupied',
|
'disabled': '_occupied',
|
||||||
},
|
},
|
||||||
query_params={
|
query_params={
|
||||||
@ -54,7 +54,7 @@ def get_cable_form(a_type, b_type):
|
|||||||
attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
|
attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
|
||||||
queryset=term_cls.objects.all(),
|
queryset=term_cls.objects.all(),
|
||||||
label=_('Power Feed'),
|
label=_('Power Feed'),
|
||||||
option_attrs={
|
context={
|
||||||
'disabled': '_occupied',
|
'disabled': '_occupied',
|
||||||
},
|
},
|
||||||
query_params={
|
query_params={
|
||||||
@ -76,7 +76,7 @@ def get_cable_form(a_type, b_type):
|
|||||||
attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
|
attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
|
||||||
queryset=term_cls.objects.all(),
|
queryset=term_cls.objects.all(),
|
||||||
label=_('Side'),
|
label=_('Side'),
|
||||||
option_attrs={
|
context={
|
||||||
'disabled': '_occupied',
|
'disabled': '_occupied',
|
||||||
},
|
},
|
||||||
query_params={
|
query_params={
|
||||||
|
@ -434,7 +434,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|||||||
device_type = DynamicModelChoiceField(
|
device_type = DynamicModelChoiceField(
|
||||||
label=_('Device type'),
|
label=_('Device type'),
|
||||||
queryset=DeviceType.objects.all(),
|
queryset=DeviceType.objects.all(),
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
},
|
},
|
||||||
selector=True
|
selector=True
|
||||||
@ -464,7 +464,7 @@ class DeviceForm(TenancyForm, NetBoxModelForm):
|
|||||||
label=_('Virtual chassis'),
|
label=_('Virtual chassis'),
|
||||||
queryset=VirtualChassis.objects.all(),
|
queryset=VirtualChassis.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'master',
|
'parent': 'master',
|
||||||
},
|
},
|
||||||
selector=True
|
selector=True
|
||||||
@ -574,7 +574,7 @@ class ModuleForm(ModuleCommonForm, NetBoxModelForm):
|
|||||||
module_type = DynamicModelChoiceField(
|
module_type = DynamicModelChoiceField(
|
||||||
label=_('Module type'),
|
label=_('Module type'),
|
||||||
queryset=ModuleType.objects.all(),
|
queryset=ModuleType.objects.all(),
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
},
|
},
|
||||||
selector=True
|
selector=True
|
||||||
@ -784,7 +784,7 @@ class ComponentTemplateForm(forms.ModelForm):
|
|||||||
device_type = DynamicModelChoiceField(
|
device_type = DynamicModelChoiceField(
|
||||||
label=_('Device type'),
|
label=_('Device type'),
|
||||||
queryset=DeviceType.objects.all(),
|
queryset=DeviceType.objects.all(),
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -802,7 +802,7 @@ class ModularComponentTemplateForm(ComponentTemplateForm):
|
|||||||
label=_('Device type'),
|
label=_('Device type'),
|
||||||
queryset=DeviceType.objects.all().all(),
|
queryset=DeviceType.objects.all().all(),
|
||||||
required=False,
|
required=False,
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -810,7 +810,7 @@ class ModularComponentTemplateForm(ComponentTemplateForm):
|
|||||||
label=_('Module type'),
|
label=_('Module type'),
|
||||||
queryset=ModuleType.objects.all(),
|
queryset=ModuleType.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'manufacturer',
|
'parent': 'manufacturer',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -269,7 +269,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
|
|||||||
interface = DynamicModelChoiceField(
|
interface = DynamicModelChoiceField(
|
||||||
queryset=Interface.objects.all(),
|
queryset=Interface.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'device',
|
'parent': 'device',
|
||||||
},
|
},
|
||||||
selector=True,
|
selector=True,
|
||||||
@ -278,7 +278,7 @@ class IPAddressForm(TenancyForm, NetBoxModelForm):
|
|||||||
vminterface = DynamicModelChoiceField(
|
vminterface = DynamicModelChoiceField(
|
||||||
queryset=VMInterface.objects.all(),
|
queryset=VMInterface.objects.all(),
|
||||||
required=False,
|
required=False,
|
||||||
option_attrs={
|
context={
|
||||||
'parent': 'virtual_machine',
|
'parent': 'virtual_machine',
|
||||||
},
|
},
|
||||||
selector=True,
|
selector=True,
|
||||||
|
@ -63,8 +63,8 @@ class DynamicModelChoiceMixin:
|
|||||||
initial_params: A dictionary of child field references to use for selecting a parent field's initial value
|
initial_params: A dictionary of child field references to use for selecting a parent field's initial value
|
||||||
null_option: The string used to represent a null selection (if any)
|
null_option: The string used to represent a null selection (if any)
|
||||||
disabled_indicator: The name of the field which, if populated, will disable selection of the
|
disabled_indicator: The name of the field which, if populated, will disable selection of the
|
||||||
choice (DEPRECATED: pass `option_attrs={'disabled': '$fieldname'}` instead)
|
choice (DEPRECATED: pass `context={'disabled': '$fieldname'}` instead)
|
||||||
option_attrs: A mapping of <option> template variables to their API data keys (optional)
|
context: A mapping of <option> template variables to their API data keys (optional)
|
||||||
selector: Include an advanced object selection widget to assist the user in identifying the desired object
|
selector: Include an advanced object selection widget to assist the user in identifying the desired object
|
||||||
"""
|
"""
|
||||||
filter = django_filters.ModelChoiceFilter
|
filter = django_filters.ModelChoiceFilter
|
||||||
@ -78,7 +78,7 @@ class DynamicModelChoiceMixin:
|
|||||||
initial_params=None,
|
initial_params=None,
|
||||||
null_option=None,
|
null_option=None,
|
||||||
disabled_indicator=None,
|
disabled_indicator=None,
|
||||||
option_attrs=None,
|
context=None,
|
||||||
selector=False,
|
selector=False,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
@ -87,7 +87,7 @@ class DynamicModelChoiceMixin:
|
|||||||
self.initial_params = initial_params or {}
|
self.initial_params = initial_params or {}
|
||||||
self.null_option = null_option
|
self.null_option = null_option
|
||||||
self.disabled_indicator = disabled_indicator
|
self.disabled_indicator = disabled_indicator
|
||||||
self.option_attrs = option_attrs or {}
|
self.context = context or {}
|
||||||
self.selector = selector
|
self.selector = selector
|
||||||
|
|
||||||
super().__init__(queryset, **kwargs)
|
super().__init__(queryset, **kwargs)
|
||||||
@ -100,7 +100,7 @@ class DynamicModelChoiceMixin:
|
|||||||
attrs['data-null-option'] = self.null_option
|
attrs['data-null-option'] = self.null_option
|
||||||
|
|
||||||
# Set any custom template attributes for TomSelect
|
# Set any custom template attributes for TomSelect
|
||||||
for var, accessor in self.option_attrs.items():
|
for var, accessor in self.context.items():
|
||||||
attrs[f'ts-{var}-field'] = accessor
|
attrs[f'ts-{var}-field'] = accessor
|
||||||
|
|
||||||
# TODO: Remove in v4.1
|
# TODO: Remove in v4.1
|
||||||
|
@ -108,7 +108,7 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
|
|||||||
'kind': 'wireless',
|
'kind': 'wireless',
|
||||||
'device_id': '$device_a',
|
'device_id': '$device_a',
|
||||||
},
|
},
|
||||||
option_attrs={
|
context={
|
||||||
'disabled': '_occupied',
|
'disabled': '_occupied',
|
||||||
},
|
},
|
||||||
label=_('Interface')
|
label=_('Interface')
|
||||||
@ -150,7 +150,7 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
|
|||||||
'kind': 'wireless',
|
'kind': 'wireless',
|
||||||
'device_id': '$device_b',
|
'device_id': '$device_b',
|
||||||
},
|
},
|
||||||
option_attrs={
|
context={
|
||||||
'disabled': '_occupied',
|
'disabled': '_occupied',
|
||||||
},
|
},
|
||||||
label=_('Interface')
|
label=_('Interface')
|
||||||
|
Loading…
Reference in New Issue
Block a user