def SettingsForm(*args, **kwargs): class _SettingsForm(BaseForm): name = StringField("User Name") email = StringField("Email") password = PasswordField("Password") confirm = PasswordField("Current Password") affiliation = StringField("Affiliation") website = URLField("Website") country = SelectField("Country", choices=SELECT_COUNTRIES_LIST) submit = SubmitField("Submit") @property def extra(self): fields_kwargs = _SettingsForm.get_field_kwargs() return build_custom_user_fields( self, include_entries=True, fields_kwargs=fields_kwargs, field_entries_kwargs={"user_id": session["id"]}, ) @staticmethod def get_field_kwargs(): user = get_current_user() field_kwargs = {"editable": True} if user.filled_all_required_fields is False: # Show all fields field_kwargs = {} return field_kwargs field_kwargs = _SettingsForm.get_field_kwargs() attach_custom_user_fields(_SettingsForm, **field_kwargs) return _SettingsForm(*args, **kwargs)
def RegistrationForm(*args, **kwargs): class _RegistrationForm(BaseForm): name = StringField("User Name", validators=[InputRequired()]) email = EmailField("Email", validators=[InputRequired()]) password = PasswordField("Password", validators=[InputRequired()]) submit = SubmitField("Submit") @property def extra(self): return build_custom_user_fields( self, include_entries=False, blacklisted_items=() ) attach_custom_user_fields(_RegistrationForm) return _RegistrationForm(*args, **kwargs)
def RegistrationForm(*args, **kwargs): class _RegistrationForm(BaseForm): name = StringField("Пользователь", validators=[InputRequired()]) email = EmailField("Почта", validators=[InputRequired()]) password = PasswordField("Пароль", validators=[InputRequired()]) submit = SubmitField("Зарегистрироваться") @property def extra(self): return build_custom_user_fields( self, include_entries=False, blacklisted_items=() ) attach_custom_user_fields(_RegistrationForm) return _RegistrationForm(*args, **kwargs)
def SettingsForm(*args, **kwargs): class _SettingsForm(BaseForm): name = StringField("Имя пользователя") email = StringField("Email") password = PasswordField("Новый пароль") confirm = PasswordField("Текущий пароль") affiliation = StringField("Учреждение") website = URLField("Сайт") country = SelectField("Страна", choices=SELECT_COUNTRIES_LIST) submit = SubmitField("Подтвердить") @property def extra(self): return build_custom_user_fields( self, include_entries=True, fields_kwargs={"editable": True}, field_entries_kwargs={"user_id": session["id"]}, ) attach_custom_user_fields(_SettingsForm, editable=True) return _SettingsForm(*args, **kwargs)
def SettingsForm(*args, **kwargs): class _SettingsForm(BaseForm): name = StringField("User Name") email = StringField("Email") password = PasswordField("Password") confirm = PasswordField("Current Password") affiliation = StringField("Affiliation") website = URLField("Website") country = SelectField("Country", choices=SELECT_COUNTRIES_LIST) submit = SubmitField("Submit") @property def extra(self): return build_custom_user_fields( self, include_entries=True, fields_kwargs={"editable": True}, field_entries_kwargs={"user_id": session["id"]}, ) attach_custom_user_fields(_SettingsForm, editable=True) return _SettingsForm(*args, **kwargs)