Add delete inventory item endpoint and enhance breadcrumb template with save/delete buttons
This commit is contained in:
parent
a3c069a126
commit
ebd2060fd8
3 changed files with 77 additions and 13 deletions
17
routes.py
17
routes.py
|
@ -344,6 +344,23 @@ def update_inventory_item(id):
|
|||
except Exception as e:
|
||||
db.session.rollback()
|
||||
return jsonify({"success": False, "error": str(e)}), 400
|
||||
|
||||
@main.route("/api/inventory/<int:id>", methods=["DELETE"])
|
||||
def delete_inventory_item(id):
|
||||
try:
|
||||
item = db.session.query(Inventory).get(id)
|
||||
|
||||
if not item:
|
||||
return jsonify({"success": False, "error": f"Item with ID {id} not found"}), 404
|
||||
|
||||
db.session.delete(item)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({"success": True}), 200
|
||||
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
return jsonify({"success": False, "error": str(e)}), 400
|
||||
|
||||
@main.route("/users")
|
||||
def list_users():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue