From 0ea4e3933fbb2bdd85429747b09a86478aa46ffb Mon Sep 17 00:00:00 2001 From: Jagraj Aulakh Date: Fri, 14 Apr 2023 16:57:58 -0400 Subject: [PATCH] #70 Add endpoint to get content by id --- backend/app/routes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/app/routes.py b/backend/app/routes.py index df606d3..d2c2166 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -149,6 +149,7 @@ def get_students_in_course(id): resp["students"].append(s.to_dict()) return jsonify(resp) + @bp.route("/course//content", methods=["GET"]) @login_required def get_content_in_course(id): @@ -162,6 +163,7 @@ def get_content_in_course(id): resp["content"].append(c.to_dict()) return jsonify(resp) + @bp.route("/course//assignments", methods=["GET"]) @login_required def get_assignments_in_course(id): @@ -315,3 +317,13 @@ def create_content(): db.session.commit() return jsonify(c.to_dict()) + + +@bp.route("/content/", methods=["GET"]) +@login_required +def get_content(id): + c = Content.query.get(id) + if not c: + return error_response(400, f"Content with id {id} does not exist") + + return jsonify(c.to_dict())