fix verbaige
This commit is contained in:
parent
ec0d3b1740
commit
a177418268
@ -17,7 +17,7 @@ from nanoid import generate
|
||||
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
|
||||
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 import cli
|
||||
|
||||
@ -198,6 +198,7 @@ def create():
|
||||
operating_systems = get_model().operating_systems_dict()
|
||||
public_keys_for_account = get_model().list_ssh_public_keys_for_account(session["account"])
|
||||
account_balance = get_account_balance(get_vms(), get_payments(), datetime.utcnow())
|
||||
account_balance_in_one_month = get_account_balance(get_vms(), get_payments(), datetime.utcnow() + timedelta(days=average_number_of_days_in_a_month))
|
||||
capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024)
|
||||
errors = list()
|
||||
|
||||
@ -207,7 +208,7 @@ def create():
|
||||
# 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:
|
||||
if vm_size["dollars_per_month"] <= account_balance_in_one_month+0.25:
|
||||
month_funded_vm_sizes[key] = vm_size
|
||||
|
||||
one_month_in_hours = float(730.5)
|
||||
@ -291,6 +292,7 @@ def create():
|
||||
csrf_token = session["csrf-token"],
|
||||
capacity_avaliable=capacity_avaliable,
|
||||
account_balance=format(account_balance, '.2f'),
|
||||
account_balance_in_one_month=format(account_balance_in_one_month, '.2f'),
|
||||
ssh_authorized_keys=public_keys_for_account,
|
||||
ssh_authorized_key_count=len(public_keys_for_account),
|
||||
no_ssh_public_keys=len(public_keys_for_account) == 0,
|
||||
|
@ -22,7 +22,7 @@ from werkzeug.exceptions import abort
|
||||
from capsulflask.auth import account_required
|
||||
|
||||
from capsulflask.db import get_model
|
||||
from capsulflask.shared import my_exec_info_message, get_account_balance
|
||||
from capsulflask.shared import my_exec_info_message, get_account_balance, average_number_of_days_in_a_month
|
||||
|
||||
bp = Blueprint("payment", __name__, url_prefix="/payment")
|
||||
|
||||
@ -151,7 +151,6 @@ def btcpay_webhook():
|
||||
def check_if_shortterm_flag_can_be_unset(email: str):
|
||||
vms = get_model().list_vms_for_account(email)
|
||||
payments = get_model().list_payments_for_account(email)
|
||||
average_number_of_days_in_a_month = 30.44
|
||||
balance = get_account_balance(vms, payments, datetime.utcnow() + timedelta(days=average_number_of_days_in_a_month))
|
||||
if balance > 0:
|
||||
get_model().clear_shortterm_flag(email)
|
||||
|
@ -23,7 +23,9 @@
|
||||
* all VMs come standard with one public IPv4 address
|
||||
* vms are billed for a minimum of 1 hour upon creation</pre>
|
||||
<pre>
|
||||
Your <a href="/console/account-balance">account balance</a>: ${{ account_balance }}
|
||||
Your <a href="/console/account-balance">current account balance</a>: ${{ account_balance }} {% if account_balance != account_balance_in_one_month %}
|
||||
|
||||
Projected account balance in one month: ${{ account_balance_in_one_month }}{% endif %}
|
||||
</pre>
|
||||
{% if cant_afford %}
|
||||
<p>Please <a href="/console/account-balance">fund your account</a> in order to create Capsuls</p>
|
||||
@ -53,8 +55,8 @@
|
||||
<pre>
|
||||
<b>NEW!</b> Short-term and Long-term Capsuls:
|
||||
|
||||
You may create a capsul even if your account balance won't
|
||||
fund it for long. It will be marked "short-term" and won't
|
||||
You may create a capsul even if your{% if account_balance != account_balance_in_one_month %} projected{% endif %} account balance
|
||||
won't fund it. It will be marked "short-term" and won't
|
||||
be backed up.
|
||||
|
||||
Short-term capsuls will be deleted as soon as your account
|
||||
|
Loading…
Reference in New Issue
Block a user