From 35ddecb5a9723e83d5a1431d36379628d33aa174 Mon Sep 17 00:00:00 2001 From: Jagraj Aulakh Date: Fri, 14 Apr 2023 16:12:52 -0400 Subject: [PATCH] #65 endpoint to delete assignment --- backend/app/routes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/app/routes.py b/backend/app/routes.py index b90a347..39e3f24 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -242,3 +242,15 @@ def get_assignment(id): return error_response(400, f"Assignment with id {id} does not exist") return jsonify(a.to_dict()) + +@bp.route("/assignment/", methods=["DELETE"]) +@login_required +def delete_assignment(id): + a = Assignment.query.get(id) + if not a: + return error_response(400, f"Assignment with id {id} does not exist") + + db.session.delete(a) + db.session.commit() + return jsonify(a.to_dict()) +