Skip to content

Commit

Permalink
Uncrispify AccountGroupForm in useradmin
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Oct 11, 2024
1 parent 1e9d859 commit 2bfe756
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
6 changes: 5 additions & 1 deletion python/nav/web/templates/useradmin/group_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ <h4>Create new group</h4>
{# GROUP FORM #}
<div class="column medium-6 large-3">
{% 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 %}
</div>

Expand Down
28 changes: 17 additions & 11 deletions python/nav/web/useradmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 2bfe756

Please sign in to comment.