From cab68b147c90caf43f0827ee223db9034dc61ed8 Mon Sep 17 00:00:00 2001 From: Jagraj Aulakh Date: Fri, 14 Apr 2023 17:00:10 -0400 Subject: [PATCH] #70 Add endpoint to delete content --- backend/app/routes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/app/routes.py b/backend/app/routes.py index d2c2166..f70aab3 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -327,3 +327,16 @@ def get_content(id): return error_response(400, f"Content with id {id} does not exist") return jsonify(c.to_dict()) + + +@bp.route("/content/", methods=["DELETE"]) +@login_required +@instructor_required +def delete_content(id): + c = Content.query.get(id) + if not c: + return error_response(400, f"Content with id {id} does not exist") + + db.session.delete(c) + db.session.commit() + return jsonify(c.to_dict())