Exemplo n.º 1
0
 def get_whole_match(cls, username):
     print username
     result = mysql_session.query(cls).filter_by(username=username).first()
     if result == None:
         print "nope!"
         return -1
     return result
Exemplo n.º 2
0
 def get_validate_user(cls, user_email, user_unsafe_password):
     user = mysql_session.query(cls).filter_by(email=user_email).first()
     
     if not user:
         return None
     
     user.id = long(user.id)
     if user.check_password(user_unsafe_password):
         return user
     else:
         return None
Exemplo n.º 3
0
 def get(cls, group_id):
     group_id = long(group_id)
     group = mysql_session.query(cls).filter_by(id=group_id).first()
     return group
Exemplo n.º 4
0
 def get_lists_by_board_id(cls, board_id):
     board_id = long(board_id)
     lists = mysql_session.query(cls).filter_by(board_id = board_id).all()
     return lists
Exemplo n.º 5
0
 def get(cls, list_id):
     list_id = long(list_id)
     _list = mysql_session.query(cls).filter_by(id = list_id).first()
     return _list
Exemplo n.º 6
0
    def get_comments_by_card_id(cls, card_id):
        card_id = long(card_id)
        comments = mysql_session.query(cls).filter_by(card_id = card_id)

        return sorted(comments, key=lambda x:x.created_at, reverse=True)
Exemplo n.º 7
0
 def get(cls, comment_id):
     comment_id = long(comment_id)
     comment = mysql_session.query(cls).filter_by(id = comment_id).first()
     return comment
Exemplo n.º 8
0
 def get(cls, user_id):
     '''warning: unsafe method, get user obj deirectly without checking password'''
     user_id = long(user_id)
     user = mysql_session.query(cls).filter_by(id=user_id).first()
     return user
Exemplo n.º 9
0
 def get_based_on_prefix(cls, prefix):
     return mysql_session.query(cls).filter(cls.username.like(prefix +'%')).all()
Exemplo n.º 10
0
    #for cases where group is observable but not the board in group for the current user
    def get_board_ids(self):
        #return r_server.lrange('/user/%d/group/%d/boards' % (self.id, group_id), 0 , -1)
        return r_server.smembers('/user/%d/boards' % self.id)

    def get_boards(self): #group_id
        from models.board import Board
        return Board.get_multi(self.get_board_ids())

    def add_board(self, board):
        return r_server.sadd('/user/%d/boards' % self.id, board.id)
    
    def get_card_ids(self):
        return r_server.smembers('/user/%d/cards' % self.id)

    def get_cards(self):
        from models.card import Card
        return Card.get_multi(self.get_card_ids())

    def add_card(self, card):
        r_server.sadd('/user/%d/cards' % self.id, card.id)

    def get_avatar(self):
        return r_server.get('/user/%d/avatar' % self.id)

    def set_avatar(self, filename):
        r_server.set('/user/%d/avatar' % self.id, filename)

User.query = mysql_session.query(User)
Exemplo n.º 11
0
 def get_all_by_user(cls,user_id):
     activities = mysql_session.query(cls).filter_by(user_id = user_id)
     return activities
Exemplo n.º 12
0
 def get_all(cls, board_id):
     activities = mysql_session.query(cls).filter_by(board_id = board_id)
     return activities
Exemplo n.º 13
0
 def get(cls, activity_id):
     activity_id = long(activity_id)
     activity = mysql_session.query(cls).filter_by(id = activity_id).first()
     return activity
Exemplo n.º 14
0
 def get(cls, board_id):
     board_id = long(board_id)
     board = mysql_session.query(cls).filter_by(id = board_id).first()
     return board