nopaque/app/admin/forms.py
2023-03-29 14:32:35 +02:00

15 lines
470 B
Python

from wtforms import BooleanField, SelectField, SubmitField
from app.forms import NopaqueForm
from app.models import Role
class UpdateUserForm(NopaqueForm):
role = SelectField('Role')
submit = SubmitField()
def __init__(self, user, *args, **kwargs):
if 'data' not in kwargs:
kwargs['data'] = {'role': user.role.hashid}
super().__init__(*args, **kwargs)
self.role.choices = [(x.hashid, x.name) for x in Role.query.all()]