Пример #1
0
def get_chapter_list():
    args = request.args
    chapter_list = []
    from models.chapter import Chapter
    chapters = Chapter.find_all(subject_id=int(args['subject_id']))
    for c in chapters:
        chapter_list.append(c.json())
    return Response(json.dumps(chapter_list), content_type='application/json')
Пример #2
0
 def get_subject_and_chapter_name(self):
     obj = {}
     from models.subject import Subject
     from models.chapter import Chapter
     subjects = Subject.all()
     for s in subjects:
         clist = Chapter.find_all(subject_id=s.id)
         temp = []
         for c in clist:
             temp.append(c.__dict__)
         obj[s.id] = temp
     return obj
Пример #3
0
def get_chapter_list():
    form = json.loads(request.get_data(as_text=True))
    all_chapter = Chapter.find_all(subject_id=form["subject_id"])
    chapter_list = [c.__dict__ for c in all_chapter]
    return Response(json_util.dumps(chapter_list, ensure_ascii=False), content_type='application/json')