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"))
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"))
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"))
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")