check_if_shortterm_flag_can_be_unset on capsul deletion

This commit is contained in:
forest 2022-02-09 12:11:38 -06:00
parent a177418268
commit 4b54aa4075

View File

@ -18,7 +18,7 @@ from capsulflask.metrics import durations as metric_durations
from capsulflask.auth import account_required
from capsulflask.db import get_model
from capsulflask.shared import my_exec_info_message, get_vm_months_float, get_account_balance, average_number_of_days_in_a_month
from capsulflask.payment import poll_btcpay_session
from capsulflask.payment import poll_btcpay_session, check_if_shortterm_flag_can_be_unset
from capsulflask import cli
bp = Blueprint("console", __name__, url_prefix="/console")
@ -140,6 +140,10 @@ def detail(id):
current_app.config["HUB_MODEL"].destroy(email=session['account'], id=id)
get_model().delete_vm(email=session['account'], id=id)
# now that the user has 1 less vm, check if thier account can fund all thier vms for
# 1 month and if so, set all thier vms to longterm
check_if_shortterm_flag_can_be_unset(session['account'])
return render_template("capsul-detail.html", vm=vm, deleted=True)
elif request.form['action'] == "force-stop":
if 'are_you_sure' not in request.form or not request.form['are_you_sure']: