#70 Add endpoint to delete content

This commit is contained in:
2023-04-14 17:00:10 -04:00
parent 0ea4e3933f
commit cab68b147c

View File

@@ -327,3 +327,16 @@ def get_content(id):
return error_response(400, f"Content with id {id} does not exist") return error_response(400, f"Content with id {id} does not exist")
return jsonify(c.to_dict()) return jsonify(c.to_dict())
@bp.route("/content/<int:id>", 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())