From 83651adda1df5b1088a0e73f8374cbc1f4757218 Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 13 Sep 2017 10:40:57 +0200 Subject: [PATCH] Stop the deletion of the last network and the last user (closes #1) --- server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server.py b/server.py index 519f811..bcc3d52 100644 --- a/server.py +++ b/server.py @@ -595,6 +595,8 @@ def page_net_del(nid): accetta richieste GET per cancellare la rete specificata.""" if 'username' not in session: return abort(403) + if Rete.query.count() <= 1: + return render_template("error.htm", error="Non puoi cancellare l'ultima rete rimasta!") rete = Rete.query.get_or_404(nid) db.session.delete(rete) db.session.commit() @@ -636,6 +638,8 @@ def page_user_del(uid): accetta richieste GET per cancellare l'utente specificato.""" if 'username' not in session: return abort(403) + if User.query.count() <= 1: + return render_template("error.htm", error="Non puoi cancellare l'ultimo utente rimasto!") utente = User.query.get_or_404(uid) db.session.delete(utente) db.session.commit()