mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Clean up form rendering
This commit is contained in:
parent
4075cc8518
commit
e0319cc894
@ -1236,17 +1236,17 @@ class InterfaceForm(InterfaceCommonForm, CustomFieldModelForm):
|
||||
'mgmt_only', 'mark_connected', 'description', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency',
|
||||
'rf_channel_width', 'tx_power', 'wireless_lans', 'untagged_vlan', 'tagged_vlans', 'tags',
|
||||
]
|
||||
# fieldsets = (
|
||||
# ('Interface', ('device', 'name', 'type', 'label', 'description', 'tags')),
|
||||
# ('Addressing', ('mac_address', 'wwn')),
|
||||
# ('Operation', ('mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
||||
# ('Related Interfaces', ('parent', 'bridge', 'lag')),
|
||||
# ('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
# ('Wireless', (
|
||||
# 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'wireless_lan_group',
|
||||
# 'wireless_lans',
|
||||
# )),
|
||||
# )
|
||||
fieldsets = (
|
||||
('Interface', ('device', 'name', 'type', 'label', 'description', 'tags')),
|
||||
('Addressing', ('mac_address', 'wwn')),
|
||||
('Operation', ('mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')),
|
||||
('Related Interfaces', ('parent', 'bridge', 'lag')),
|
||||
('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')),
|
||||
('Wireless', (
|
||||
'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'wireless_lan_group',
|
||||
'wireless_lans',
|
||||
)),
|
||||
)
|
||||
widgets = {
|
||||
'device': forms.HiddenInput(),
|
||||
'type': StaticSelect(),
|
||||
@ -1358,9 +1358,6 @@ class PopulateDeviceBayForm(BootstrapMixin, forms.Form):
|
||||
|
||||
|
||||
class InventoryItemForm(CustomFieldModelForm):
|
||||
device = DynamicModelChoiceField(
|
||||
queryset=Device.objects.all()
|
||||
)
|
||||
parent = DynamicModelChoiceField(
|
||||
queryset=InventoryItem.objects.all(),
|
||||
required=False,
|
||||
@ -1401,6 +1398,9 @@ class InventoryItemForm(CustomFieldModelForm):
|
||||
('Hardware', ('manufacturer', 'part_id', 'serial', 'asset_tag')),
|
||||
('Component', ('component_type', 'component_id')),
|
||||
)
|
||||
widgets = {
|
||||
'device': forms.HiddenInput(),
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
|
@ -706,6 +706,7 @@ class ComponentCreateView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View
|
||||
form, model_form = self.initialize_forms(request)
|
||||
|
||||
return render(request, self.template_name, {
|
||||
'obj': self.queryset.model,
|
||||
'obj_type': self.queryset.model._meta.verbose_name,
|
||||
'replication_form': form,
|
||||
'form': model_form,
|
||||
@ -724,6 +725,7 @@ class ComponentCreateView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View
|
||||
return redirect(self.get_return_url(request))
|
||||
|
||||
return render(request, self.template_name, {
|
||||
'obj': self.queryset.model,
|
||||
'obj_type': self.queryset.model._meta.verbose_name,
|
||||
'replication_form': form,
|
||||
'form': model_form,
|
||||
|
@ -29,7 +29,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit">
|
||||
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit mt-5">
|
||||
{% csrf_token %}
|
||||
|
||||
{% block form %}
|
||||
@ -47,7 +47,11 @@
|
||||
<h5 class="offset-sm-3">{{ group }}</h5>
|
||||
</div>
|
||||
{% for name in fields %}
|
||||
{% render_field form|getfield:name %}
|
||||
{% with field=form|getfield:name %}
|
||||
{% if not field.field.widget.is_hidden %}
|
||||
{% render_field field %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user