예제 #1
0
파일: group.py 프로젝트: lypinggan/42ic
    def search(self, keywords):
        criteria = []
        for keyword in keywords.split():

            keyword = "%" + keyword + "%"

            criteria.append(db.or_(Group.name.ilike(keyword)))

        q = reduce(db.and_, criteria)
        return self.filter(q).order_by(Group.num_members.desc())
예제 #2
0
파일: group.py 프로젝트: lypinggan/42ic
    def search(self, keywords):
        criteria = []
        for keyword in keywords.split():

            keyword = "%" + keyword + "%"

            criteria.append(db.or_(Group_Topic.title.ilike(keyword), Group_Topic.description.ilike(keyword)))

        q = reduce(db.and_, criteria)
        return self.filter(q).order_by(Group_Topic.num_comment.desc())
예제 #3
0
파일: question.py 프로젝트: lypinggan/42rd
    def search(self, keywords):
        criteria = []
        for keyword in keywords.split():

            keyword = "%" + keyword + "%"

            criteria.append(db.or_(Question.title.ilike(keyword), Question.description.ilike(keyword)))

        q = reduce(db.and_, criteria)
        return self.filter(q).order_by(Question.votes.desc(), Question.id.desc())
예제 #4
0
파일: question.py 프로젝트: lypinggan/42rd
    def tags_search(self, keywords):

        criteria = []

        for keyword in keywords.split():

            keyword = "%" + keyword + "%"

            criteria.append(db.or_(Tag.slug.ilike(keyword), Tag.description.ilike(keyword)))
        q = reduce(db.and_, criteria)
        return self.filter(q).distinct()
예제 #5
0
파일: users.py 프로젝트: lypinggan/42rd
    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