mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Improve preferences form rendering
This commit is contained in:
@ -8,20 +8,29 @@
|
|||||||
<form method="post" action="" id="preferences-update">
|
<form method="post" action="" id="preferences-update">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{% comment %}
|
|
||||||
{% for group, fields in form.Meta.fieldsets %}
|
{% for group, fields in form.Meta.fieldsets %}
|
||||||
<div class="field-group my-5">
|
<div class="field-group my-5">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<h5 class="offset-sm-3">{{ group }}</h5>
|
<h5 class="offset-sm-3">{{ group }}</h5>
|
||||||
</div>
|
</div>
|
||||||
{% for name in fields %}
|
{% for name in fields %}
|
||||||
{% render_field form|getfield:name %}
|
{% render_field form|getfield:name %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endcomment %}
|
|
||||||
|
|
||||||
{% render_form form %}
|
{% with plugin_fields=form.plugin_fields %}
|
||||||
|
{% if plugin_fields %}
|
||||||
|
<div class="field-group my-5">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<h5 class="offset-sm-3">Plugins</h5>
|
||||||
|
</div>
|
||||||
|
{% for name in plugin_fields %}
|
||||||
|
{% render_field form|getfield:name %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
<div class="text-end my-3">
|
<div class="text-end my-3">
|
||||||
<a class="btn btn-outline-secondary" href="{% url 'user:preferences' %}">Cancel</a>
|
<a class="btn btn-outline-secondary" href="{% url 'user:preferences' %}">Cancel</a>
|
||||||
|
@ -44,6 +44,15 @@ class UserConfigForm(BootstrapMixin, forms.ModelForm, metaclass=UserConfigFormMe
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = UserConfig
|
model = UserConfig
|
||||||
fields = ()
|
fields = ()
|
||||||
|
fieldsets = (
|
||||||
|
('User Interface', (
|
||||||
|
'pagination.per_page',
|
||||||
|
'ui.colormode',
|
||||||
|
)),
|
||||||
|
('Miscellaneous', (
|
||||||
|
'data_format',
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, *args, instance=None, **kwargs):
|
def __init__(self, *args, instance=None, **kwargs):
|
||||||
|
|
||||||
@ -61,6 +70,12 @@ class UserConfigForm(BootstrapMixin, forms.ModelForm, metaclass=UserConfigFormMe
|
|||||||
|
|
||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def plugin_fields(self):
|
||||||
|
return [
|
||||||
|
name for name in self.fields.keys() if name.startswith('plugins.')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class TokenForm(BootstrapMixin, forms.ModelForm):
|
class TokenForm(BootstrapMixin, forms.ModelForm):
|
||||||
key = forms.CharField(
|
key = forms.CharField(
|
||||||
|
Reference in New Issue
Block a user