nopaque/app/admin/forms.py

15 lines
470 B
Python
Raw Normal View History

from wtforms import BooleanField, SelectField, SubmitField
from app.forms import NopaqueForm
from app.models import Role
2023-03-29 12:32:35 +00:00
class UpdateUserForm(NopaqueForm):
role = SelectField('Role')
2023-03-29 12:32:35 +00:00
submit = SubmitField()
2023-03-29 12:32:35 +00:00
def __init__(self, user, *args, **kwargs):
if 'data' not in kwargs:
kwargs['data'] = {'role': user.role.hashid}
super().__init__(*args, **kwargs)
2022-09-02 11:08:01 +00:00
self.role.choices = [(x.hashid, x.name) for x in Role.query.all()]