nopaque/app/admin/forms.py

17 lines
537 B
Python
Raw Normal View History

2023-03-31 07:14:21 +00:00
from flask_wtf import FlaskForm
from wtforms import SelectField, SubmitField
from app.models import Role
2023-03-31 07:14:21 +00:00
class UpdateUserForm(FlaskForm):
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}
2023-03-31 07:14:21 +00:00
if 'prefix' not in kwargs:
kwargs['prefix'] = 'update-user-form'
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()]