class GroupAdminForm(Form): name = StringField(_l(u'Name'), filters=(strip,), validators=[required()]) description = StringField(_l(u'Description'), filters=(strip,)) public = BooleanField( _l(u'Public'), widget=widgets.BooleanWidget(on_off_mode=True)) roles = fields.Select2MultipleField( _l(u'Roles'), choices=lambda: [(r.name, r.label) for r in Role.assignable_roles()],)
class BaseUserAdminForm(Form): email = StringField( _l("Email"), description=_l("Users log in with their email address."), view_widget=widgets.EmailWidget(), filters=(strip,), validators=[required()], ) first_name = StringField( _l("First Name"), description=_l("ex: John"), filters=(strip,), validators=[required()], ) last_name = StringField( _l("Last Name"), description=_l("ex: Smith"), filters=(strip,), validators=[required()], ) can_login = BooleanField( _l("Login enabled"), description=_l("If unchecked, user will not be able to connect."), widget=widgets.BooleanWidget(), ) groups = QuerySelect2Field( _l("Groups"), validators=(optional(),), multiple=True, collection_class=set, query_factory=lambda: Group.query.order_by(sa.sql.func.lower(Group.name).asc()), get_label="name", ) roles = Select2MultipleField( _l("Roles"), description=_l( "Prefer groups to manage access rights. Directly assigning roles " "to users is possible but discouraged." ), choices=lambda: [(r.name, r.label) for r in Role.assignable_roles()], ) password = StringField( _l("New Password"), description=_l("If empty the current password will not be changed."), widget=widgets.PasswordInput(autocomplete="off"), )