diff --git a/calsocial/forms.py b/calsocial/forms.py index 6d6e631..e7adf73 100644 --- a/calsocial/forms.py +++ b/calsocial/forms.py @@ -17,6 +17,8 @@ """Forms for Calendar.social """ +from enum import Enum + from flask_babelex import lazy_gettext as _ from flask_security.forms import LoginForm as BaseLoginForm from flask_wtf import FlaskForm @@ -173,6 +175,9 @@ class TimezoneField(SelectField): class EnumField(SelectField): def __init__(self, enum_type, translations, *args, **kwargs): + if not issubclass(enum_type, Enum): + raise TypeError('enum_type must be a subclass of Enum') + kwargs.update({'choices': [(value, None) for value in enum_type]}) self.data = None self.enum_type = enum_type