def authenticate(self, login, password): user = self.filter(db.or_(User.username==login, User.email==login)).first() if user: authenticated = user.check_password(password) else: authenticated = False return user, authenticated
def authenticate(self, login, password): user = self.filter(db.or_(User.username == login, User.email == login)).first() if user: authenticated = user.check_password(password) else: authenticated = False return user, authenticated
def search(self, keywords): criteria = [] for keyword in keywords.split(): keyword = '%' + keyword + '%' criteria.append(db.or_(Post.title.ilike(keyword), Post.description.ilike(keyword), Post.link.ilike(keyword), Post.tags.ilike(keyword), User.username.ilike(keyword))) q = reduce(db.and_, criteria) return self.filter(q).join(User).distinct()
def search(self, keywords): criteria = [] for keyword in keywords.split(): keyword = '%' + keyword + '%' criteria.append( db.or_(Post.title.ilike(keyword), Post.description.ilike(keyword), Post.link.ilike(keyword), Post.tags.ilike(keyword), User.username.ilike(keyword))) q = reduce(db.and_, criteria) return self.filter(q).join(User).distinct()