diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-06-19 11:17:34 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-06-19 11:53:56 +0200 |
commit | ee42cbd32355669304c63cbffe2c9d758e373fc2 (patch) | |
tree | 21aaeaed4fecccb6994b1c603912413082b88b75 /ogcp/forms | |
parent | 2ae6f37e60955521eb8637127b37c76c19a7f607 (diff) |
views: make password optional in user/edit
Add the option to leave the password fields empty in the form.
When the passwords are not set the user keeps the old password
configuration.
Define a EditUserForm based on UserForm in forms/auth.py to remove
the InputRequired validator in the password fields.
Update the html template to make the password fields optional.
Diffstat (limited to 'ogcp/forms')
-rw-r--r-- | ogcp/forms/auth.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ogcp/forms/auth.py b/ogcp/forms/auth.py index 72afe23..d85931b 100644 --- a/ogcp/forms/auth.py +++ b/ogcp/forms/auth.py @@ -9,7 +9,7 @@ from wtforms import ( Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField, StringField, RadioField, PasswordField, SelectMultipleField, widgets ) -from wtforms.validators import InputRequired +from wtforms.validators import InputRequired, Optional from flask_wtf import FlaskForm from flask_babel import lazy_gettext as _l from flask_babel import _ @@ -55,6 +55,13 @@ class UserForm(FlaskForm): ) +class EditUserForm(UserForm): + def __init__(self, *args, **kwargs): + super(EditUserForm, self).__init__(*args, **kwargs) + self.pwd.validators = [Optional()] + self.pwd_confirm.validators = [Optional()] + + class DeleteUserForm(FlaskForm): username = HiddenField( validators=[InputRequired()] |