Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncrispify AccountGroupForm in useradmin #3138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading