예제 #1
0
    def get(self, id):
        load_options = subqueryload(Author.books)
        author = Author.find_or_fail(id, load_options=load_options)
        data = author.json()
        data['books'] = [book.json() for book in author.books]

        return data
예제 #2
0
    def put(self, id):
        author = Author.find_or_fail(id)

        data = self.parser.parse_args()
        for key, value in data.items():
            setattr(author, key, value)
        author.save()

        return author.json()
예제 #3
0
    def delete(self, id):
        author = Author.find_or_fail(id)
        author.delete()

        return None, 204