1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-21 23:24:18 +00:00

Stop the deletion of the last network and the last user (closes #1)

This commit is contained in:
Steffo 2017-09-13 10:40:57 +02:00
parent b48db38b7a
commit 83651adda1

View file

@ -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()