Merge branch 'master' into yolocolo
This commit is contained in:
commit
d6f2f6d0bf
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
notes.txt
|
||||
.env
|
||||
.env.bak
|
||||
.vscode
|
||||
|
||||
*.pyc
|
||||
|
@ -199,6 +199,14 @@ def create():
|
||||
capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024)
|
||||
errors = list()
|
||||
|
||||
affordable_vm_sizes = dict()
|
||||
for key, vm_size in vm_sizes.items():
|
||||
# if a user deposits $7.50 and then creates an f1-s vm which costs 7.50 a month,
|
||||
# then they have to delete the vm and re-create it, they will not be able to, they will have to pay again.
|
||||
# so for UX it makes a lot of sense to give a small margin of 25 cents for usability sake
|
||||
if vm_size["dollars_per_month"] <= account_balance+0.25:
|
||||
affordable_vm_sizes[key] = vm_size
|
||||
|
||||
if request.method == "POST":
|
||||
if "csrf-token" not in request.form or request.form['csrf-token'] != session['csrf-token']:
|
||||
return abort(418, f"u want tea")
|
||||
@ -209,6 +217,8 @@ def create():
|
||||
errors.append("Size is required")
|
||||
elif size not in vm_sizes:
|
||||
errors.append(f"Invalid size {size}")
|
||||
elif size not in affordable_vm_sizes:
|
||||
errors.append(f"Your account must have enough credit to run an {size} for 1 month before you will be allowed to create it")
|
||||
|
||||
if not os:
|
||||
errors.append("OS is required")
|
||||
@ -260,13 +270,6 @@ def create():
|
||||
|
||||
return redirect(f"{url_for('console.index')}?created={id}")
|
||||
|
||||
affordable_vm_sizes = dict()
|
||||
for key, vm_size in vm_sizes.items():
|
||||
# if a user deposits $7.50 and then creates an f1-s vm which costs 7.50 a month,
|
||||
# then they have to delete the vm and re-create it, they will not be able to, they will have to pay again.
|
||||
# so for UX it makes a lot of sense to give a small margin of 25 cents for usability sake
|
||||
if vm_size["dollars_per_month"] <= account_balance+0.25:
|
||||
affordable_vm_sizes[key] = vm_size
|
||||
|
||||
for error in errors:
|
||||
flash(error)
|
||||
|
Loading…
Reference in New Issue
Block a user