示例#1
0
 def validate_id(self, field):
     role = None
     if field.data is None:
         raise ValidationError(u'没有此用户')
     if self.role.data == 'user':
         role = User.query.get(field.data)
     elif self.role.data == 'vendor':
         role = Vendor.query.get(field.data)
     if not role:
         raise ValidationError(u'没有此用户')
     if role.email and role.email_confirmed:
         raise ValidationError('邮箱已绑定, 暂时无法修改')
     if not self.email.data:
         self.email.data = role.email
     self.email_confirmed = role.email_confirmed
示例#2
0
文件: forms.py 项目: xeonpc/WanMuJia
 def __init__(self, *args, **kwargs):
     super(ResetPasswordDetailForm, self).__init__(*args, **kwargs)
     if USER_RESET_PASSWORD_MOBILE not in session:
         raise ValidationError('参数错误, 注册失败')
     self.mobile.data = session[USER_RESET_PASSWORD_MOBILE]
示例#3
0
文件: forms.py 项目: xeonpc/WanMuJia
 def validate_mobile(self, field):
     if not User.query.filter_by(mobile=field.data).first():
         raise ValidationError('该手机号码未注册用户!')
示例#4
0
文件: forms.py 项目: xeonpc/WanMuJia
 def __init__(self, *args, **kwargs):
     super(RegistrationDetailForm, self).__init__(*args, **kwargs)
     if USER_REGISTER_MOBILE not in session:
         raise ValidationError('参数错误, 注册失败')
     self.mobile.data = session[USER_REGISTER_MOBILE]
示例#5
0
文件: forms.py 项目: xeonpc/WanMuJia
 def validate_form(self, field):
     if field.data != USER_REGISTER_EMAIL:
         raise ValidationError()
示例#6
0
文件: forms.py 项目: xeonpc/WanMuJia
 def validate_nothing(self, field):
     if self.type == USER_PASSWORD_SETTING:
         if not current_user.verify_password(self.old_password.data):
             raise ValidationError('原密码错误!')
示例#7
0
 def validate_nothing(self, field):
     if self.sms_type == USER_RESET_PASSWORD:
         if not User.query.filter_by(mobile=self.mobile.data).first():
             raise ValidationError('该手机号码未注册用户!')