Ejemplo n.º 1
0
 def post_class(payload):
     try:
         data = request.get_json()
         name = data['class_name']
         address = data['address']
         inst = data['instructor']
         new_class = Classes(class_name=name,
                             address=address,
                             instructor=inst)
         new_class.insert()
     except Exception:
         abort(400)
     return jsonify({'success': True, 'classes': new_class.format()})
Ejemplo n.º 2
0
    def create_class(payload):
        name = request.get_json()['name']
        start_time = request.get_json()['start_time']
        teacher_id = request.get_json()['teacher_id']
        course_id = request.get_json()['course_id']
        try:
            claass = Classes(name=name,
                             start_time=start_time,
                             teacher_id=teacher_id,
                             course_id=course_id)
            claass.insert()

            return jsonify({"success": True, "Courses": claass.format()})
        except BaseException:
            abort(422)