Skip to content

Commit

Permalink
Merge pull request #3090 from Uninett/uncrispify/ChangePasswordForm
Browse files Browse the repository at this point in the history
Uncrispify ChangePasswordForm
  • Loading branch information
stveit authored Oct 4, 2024
2 parents 86276ac + ef4d14c commit 2899bea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
6 changes: 5 additions & 1 deletion python/nav/web/templates/webfront/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@
</p>
{% else %}
<form method="post" id="change-password-form" action="{% url 'webfront-preferences-changepassword' %}">
{% crispy password_form %}
{% if password_form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' with form=password_form %}
{% else %}
{{ password_form }}
{% endif %}
</form>
{% endif %}

Expand Down
25 changes: 14 additions & 11 deletions python/nav/web/webfront/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
from django.forms.models import modelformset_factory
from django.urls import reverse
from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column, HTML, Submit
from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column, HTML
from nav.models.profiles import NavbarLink, Account
from nav.web.crispyforms import (
CheckBox,
NavSubmit,
SubmitField,
set_flat_form_attributes,
FlatFieldset,
)


Expand Down Expand Up @@ -96,16 +97,18 @@ def __init__(self, *args, **kwargs):

super(ChangePasswordForm, self).__init__(*args, **kwargs)

self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Fieldset(
'Change password',
'old_password',
'new_password1',
'new_password2',
Submit('submit', 'Change password', css_class='small'),
)
self.attrs = set_flat_form_attributes(
form_fields=[
FlatFieldset(
legend='Change password',
fields=[
self['old_password'],
self['new_password1'],
self['new_password2'],
SubmitField(value='Change password', css_classes='small'),
],
)
],
)

def clean_old_password(self):
Expand Down

0 comments on commit 2899bea

Please sign in to comment.