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

Clean up form display

This commit is contained in:
jeremystretch
2021-12-28 08:54:03 -05:00
parent ba85101d30
commit 8ca09ec07f
6 changed files with 24 additions and 31 deletions

View File

@ -1097,6 +1097,7 @@ class ConsolePortForm(CustomFieldModelForm):
widgets = {
'device': forms.HiddenInput(),
'type': StaticSelect(),
'speed': StaticSelect(),
}
@ -1114,6 +1115,7 @@ class ConsoleServerPortForm(CustomFieldModelForm):
widgets = {
'device': forms.HiddenInput(),
'type': StaticSelect(),
'speed': StaticSelect(),
}
@ -1234,6 +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',
# )),
# )
widgets = {
'device': forms.HiddenInput(),
'type': StaticSelect(),

View File

@ -707,8 +707,8 @@ class ComponentCreateView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View
return render(request, self.template_name, {
'obj_type': self.queryset.model._meta.verbose_name,
'form': form,
'model_form': model_form,
'replication_form': form,
'form': model_form,
'return_url': self.get_return_url(request),
})
@ -725,8 +725,8 @@ class ComponentCreateView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View
return render(request, self.template_name, {
'obj_type': self.queryset.model._meta.verbose_name,
'form': form,
'model_form': model_form,
'replication_form': form,
'form': model_form,
'return_url': self.get_return_url(request),
})

View File

@ -2,6 +2,6 @@
{% load form_helpers %}
{% block form %}
{% render_form form %}
{% render_form model_form %}
{% render_form replication_form %}
{{ block.super }}
{% endblock form %}

View File

@ -1,16 +0,0 @@
{% extends 'generic/object_edit.html' %}
{% block buttons %}
<a class="btn btn-outline-danger" href="{{ return_url }}">Cancel</a>
{% if component_type == 'interface' and perms.ipam.add_ipaddress %}
<button type="submit" name="_assignip" class="btn btn-outline-success">
Create & Assign IP Address
</button>
{% endif %}
<button type="submit" name="_addanother" class="btn btn-outline-primary">
Create & Add Another
</button>
<button type="submit" name="_create" class="btn btn-primary">
Create
</button>
{% endblock %}

View File

@ -40,7 +40,7 @@
{# Render grouped fields according to Form #}
{% for group, fields in form.Meta.fieldsets %}
<div class="field-group my-5">
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">{{ group }}</h5>
</div>
@ -51,7 +51,7 @@
{% endfor %}
{% if form.custom_fields %}
<div class="field-group my-5">
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">Custom Fields</h5>
</div>
@ -60,7 +60,7 @@
{% endif %}
{% if form.comments %}
<div class="field-group my-5">
<div class="field-group mb-5">
<h5 class="text-center">Comments</h5>
{% render_field form.comments %}
</div>
@ -68,7 +68,7 @@
{% else %}
{# Render all fields in a single group #}
<div class="field-group my-5">
<div class="field-group mb-5">
{% block form_fields %}{% render_form form %}{% endblock %}
</div>
{% endif %}

View File

@ -346,11 +346,7 @@ class ExpandableNameField(forms.CharField):
if not self.help_text:
self.help_text = """
Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range
are not supported. Examples:
<ul>
<li><code>[ge,xe]-0/0/[0-9]</code></li>
<li><code>e[0-3][a-d,f]</code></li>
</ul>
are not supported. Example: <code>[ge,xe]-0/0/[0-9]</code>
"""
def to_python(self, value):