def put(self, chapter_id):
        data = Chapter.parser.parse_args()
        chapter = ChapterModel.findById(chapter_id)
        print(chapter_id)
        if chapter is None:
            chapter = ChapterModel(data["chapter_name"], data["book_id"],
                                   data["chapter_description"],
                                   data["chapter_order"])
        else:
            chapter.chapter_name = data['chapter_name']
            chapter.book_id = data['book_id']
            chapter.chapter_description = data['chapter_description']
            chapter.chapter_order = data['chapter_order']
            chapter.chapter_update = datetime.now()

        chapter.saveToDb()
        return chapter.json()
Beispiel #2
0
    def put(self, chapter_id):
        data = Chapter.parser.parse_args()

        chapter = ChapterModel.find_by_id(chapter_id)

        if chapter is None:
            chapter = ChapterModel(**data)
        else:
            chapter.book_id = data['book_id']
            chapter.chapter_name = data['chapter_name']
            chapter.chapter_description = data['chapter_description']
            chapter.chapter_order = data['chapter_order']
            chapter.chapter_update = datetime.now()

        chapter.save_to_db()

        return chapter.json()