Example #1
0
    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
Example #2
0
    def search(self, keywords):

        criteria = []

        for keyword in keywords.split():
            keyword = '%' + keyword + '%'
            criteria.append(db.or_(Post.title.ilike(keyword),
                                   Post.content.ilike(keyword),
                                   Post.tags.ilike(keyword)
                                   ))

        q = reduce(db.and_, criteria)
        return self.filter(q)
Example #3
0
 def search(self, key):
     query = self.filter(db.or_(User.email==key,
                                User.nickname.ilike('%'+key+'%'),
                                User.username.ilike('%'+key+'%')))
     return query