Allow to delete npcs

This commit is contained in:
Thomas Rubini 2023-03-29 10:11:55 +02:00
parent c330253306
commit 3c8f9a1ada
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
3 changed files with 15 additions and 1 deletions

View File

@ -162,4 +162,12 @@ def set_npc():
db.session.commit()
return {"error": 0}
return {"error": 0}
@routes_api_admin.route("/deleteNpc", methods=["GET", "POST"])
@require_admin(api=True)
def delete_npc():
input_npc_id = flask.request.json["npc_id"]
db.session.execute(delete(Npc).where(Npc.NPC_ID==input_npc_id))
db.session.commit()
return {}

View File

@ -112,3 +112,8 @@ function saveFormNpc(){
makeAPIRequest("admin/setNpc", {"npc": data, "lang": "FR"}, {"content": "json"})
}
async function deleteNpc(){
let npc_id = npc.querySelector("#npc_id").value;
await makeAPIRequest("admin/deleteNpc", {"npc_id": npc_id, "lang": "FR"}, {"content": "json"});
document.location = "/admin";
}

View File

@ -31,5 +31,6 @@
</section>
<button onclick="saveFormNpc()">Save changes</button>
<button onclick="deleteNpc()">Delete Npc</button>
</body>
</html>