def post(self):
        data = Chapter.parser.parse_args()

        chapter = ChapterModel(data["chapter_name"], data["book_id"],
                               data["chapter_description"],
                               data["chapter_order"])
        try:
            chapter.chapter_creation = datetime.now()
            chapter.saveToDb()
        except:
            return {"message": "An error occured creating the chapter."}, 500
        return chapter.json(), 201
    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()