示例#1
0
 def validate_link(self, field):
     posts = Post.query.public().filter_by(link=field.data)
     if self.post:
         posts = posts.filter(db.not_(Post.id == self.post.id))
     if posts.count():
         raise ValidationError(
             message=gettext("This link has already been posted"))
示例#2
0
    def validate_username(self, field):
        user = User.query.filter(db.and_(
                                 User.username.like(field.data),
                                 db.not_(User.id == self.user.id))).first()

        if user:
            raise ValidationError(message=gettext("This username is taken"))
示例#3
0
    def validate_username(self, field):
        user = User.query.filter(
            db.and_(User.username.like(field.data),
                    db.not_(User.id == self.user.id))).first()

        if user:
            raise ValidationError(message=gettext("This username is taken"))
示例#4
0
文件: post.py 项目: 04052038/newsmeme
 def validate_link(self, field):
     posts = Post.query.public().filter_by(link=field.data)
     if self.post:
         posts = posts.filter(db.not_(Post.id == self.post.id))
     if posts.count():
         raise ValidationError(
             message=gettext("This link has already been posted"))
示例#5
0
 def validate_email(self, field):
     user = User.query.filter(db.and_(
                              User.email.like(field.data),
                              db.not_(User.id==self.user.id))).first()
     if user:
         raise ValidationError, gettext("This email is taken")