Skip to content

Commit

Permalink
Updated time allocation and time limit preview
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Feb 12, 2024
1 parent 005cd81 commit b28ac4f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 1 addition & 4 deletions frontend/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5220,16 +5220,13 @@ def create_account_sub(email):
def create_subscription(
user, stripe_sub_id, end_date, allocation, stripe_cus_id, will_renew
):
time_left = max(0, user.allocated_seconds - user.billed_seconds)
sub_amount = max(allocation - time_left, 0)

# Make sure we don't create a duplicate subscription and allocation
try:
sub = Subscription.objects.get(subscriber=user, end_date=end_date)
except Subscription.DoesNotExist:
alloc = ResourceAllocation.objects.create(
code=get_random_string(32),
allocation_seconds=sub_amount,
allocation_seconds=allocation,
note=ResourceAllocation.SUBSCRIPTION,
)
alloc.redeem(user)
Expand Down
3 changes: 2 additions & 1 deletion frontend/templates/frontend/form/type_head.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ function calc_selection_changed() {
viewer.styles.atoms_displayLabels_3D = false;
}
}
software = document.getElementById("calc_software");
msg = document.getElementById("cloud_num_cores");
if(msg) {
if(choice.value == "Conformational Search" || choice.value == "Constrained Conformational Search") {
if(software.value == "NWChem" || choice.value == "Conformational Search" || choice.value == "Constrained Conformational Search") {
// Hardcoded values for now...
$("#cloud_num_cores").html({% if request.user.is_trial %}"4"{% else %}"8"{% endif %});
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/templates/frontend/launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</div>
{% if IS_CLOUD %}
<div class="cloud_comp_info">
<span id="cloud_num_cores">1 to 4</span> core will be used (maximum runtime: <span id="cloud_timeout">{% if request.user.is_trial %}5 minutes{% elif request.user.is_subscriber %}6 hours{% else %}15 minutes{% endif %}</span></span>)
<span id="cloud_num_cores">1 to 4</span> core will be used (maximum runtime: <span id="cloud_timeout">{% if request.user.is_trial %}5 minutes{% elif request.user.is_subscriber %}24 hours{% else %}15 minutes{% endif %}</span></span>)
{% if request.user.is_trial %}
<br>
<a href="/create_full_account/">You are using a trial account. Convert to a free full account to unlock more computing power and longer runtimes</a>
Expand Down

0 comments on commit b28ac4f

Please sign in to comment.