From 2bfe7561f42cb832fbcdfef8b6bade72735e771f Mon Sep 17 00:00:00 2001 From: Johanna England Date: Fri, 11 Oct 2024 15:30:41 +0200 Subject: [PATCH] Uncrispify AccountGroupForm in useradmin --- .../web/templates/useradmin/group_detail.html | 6 +++- python/nav/web/useradmin/forms.py | 28 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/python/nav/web/templates/useradmin/group_detail.html b/python/nav/web/templates/useradmin/group_detail.html index b6b09515e6..9b217386ec 100644 --- a/python/nav/web/templates/useradmin/group_detail.html +++ b/python/nav/web/templates/useradmin/group_detail.html @@ -41,7 +41,11 @@

Create new group

{# GROUP FORM #}
{% if group_form %} - {% crispy group_form %} + {% if group_form.attrs %} + {% include 'custom_crispy_templates/flat_form.html' with form=group_form %} + {% else %} + {{ group_form }} + {% endif %} {% endif %}
diff --git a/python/nav/web/useradmin/forms.py b/python/nav/web/useradmin/forms.py index 67a05eb3df..2a4ab10c4e 100644 --- a/python/nav/web/useradmin/forms.py +++ b/python/nav/web/useradmin/forms.py @@ -31,7 +31,7 @@ Field, HTML, ) -from nav.web.crispyforms import set_flat_form_attributes, SubmitField +from nav.web.crispyforms import set_flat_form_attributes, FlatFieldset, SubmitField from nav.models.profiles import Account, AccountGroup, PrivilegeType from nav.models.manage import Organization @@ -48,16 +48,22 @@ class AccountGroupForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(AccountGroupForm, self).__init__(*args, **kwargs) - self.helper = FormHelper() - self.helper.form_action = '' - self.helper.form_method = 'post' - self.helper.layout = Layout( - Fieldset( - 'Group info', - 'name', - 'description', - Submit('submit_group', 'Save changes', css_class='small'), - ) + + self.attrs = set_flat_form_attributes( + form_fields=[ + FlatFieldset( + legend="Group info", + fields=[ + self["name"], + self["description"], + SubmitField( + name="submit_group", + value="Save changes", + css_classes="small", + ), + ], + ) + ] ) class Meta(object):