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()]