예제 #1
0
    def get(self, username):
        user = User.get_by_username(username)
        if not user:
            raise InvalidUsage(404, 'User not found')

        posts = user.favorites. \
            order_by(Post.created_at.desc())

        return posts
예제 #2
0
    def get(self, username):
        user = User.get_by_username(username)
        if not user:
            raise InvalidUsage(404, 'User not found')

        posts = user.posts. \
            order_by(Post.created_at.desc()). \
            filter_by(owner_id=user.id)

        return posts
예제 #3
0
 def get(self, username):
     user = User.get_by_username(username)
     if not user:
         raise InvalidUsage(404, 'User not found')
     return user