2023-03-31 07:14:21 +00:00
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from wtforms import SelectField, SubmitField
|
2023-03-29 07:25:08 +00:00
|
|
|
from app.models import Role
|
2019-09-10 11:49:01 +00:00
|
|
|
|
|
|
|
|
2023-03-31 07:14:21 +00:00
|
|
|
class UpdateUserForm(FlaskForm):
|
2022-02-08 11:26:20 +00:00
|
|
|
role = SelectField('Role')
|
2023-03-29 12:32:35 +00:00
|
|
|
submit = SubmitField()
|
2019-09-10 11:49:01 +00:00
|
|
|
|
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'
|
2021-09-13 14:36:48 +00:00
|
|
|
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()]
|