diff --git a/coldfront/core/allocation/views.py b/coldfront/core/allocation/views.py index f5e2acdd6..ce59ba295 100644 --- a/coldfront/core/allocation/views.py +++ b/coldfront/core/allocation/views.py @@ -2049,6 +2049,10 @@ def post(self, request, *args, **kwargs): if form_data.get('end_date_extension') != 0: change_requested = True + + # if requested resource is on NESE, add to vars + nese = bool(allocation_obj.resources.filter(name__contains="nesetape")) + if attrs_to_change: for entry in formset: formset_data = entry.cleaned_data @@ -2056,7 +2060,6 @@ def post(self, request, *args, **kwargs): new_value = formset_data.get('new_value') # require nese shares to be divisible by 20 tbs = int(new_value) if formset_data['name'] == 'Storage Quota (TB)' else False - nese = bool(allocation_obj.resources.filter(name__contains="nesetape")) if nese and tbs and tbs % 20 != 0: messages.error(request, "Tier 3 quantity must be a multiple of 20.") return HttpResponseRedirect(reverse('allocation-change', kwargs={'pk': pk})) @@ -2097,17 +2100,19 @@ def post(self, request, *args, **kwargs): for a in attribute_changes_to_make if a[0].allocation_attribute_type.name == 'Storage Quota (TB)' ] - # if requested resource is on NESE, add to vars - nese = bool(allocation_obj.resources.filter(name__contains="nesetape")) email_vars = {'justification': justification} if quantity: quantity_num = int(float(quantity[0][1])) difference = quantity_num - int(float(allocation_obj.size)) used_percentage = allocation_obj.get_parent_resource.used_percentage + current_size = allocation_obj.size + if nese: + current_size = round(current_size, -1) + difference = round(difference, -1) email_vars['quantity'] = quantity_num email_vars['nese'] = nese - email_vars['current_size'] = allocation_obj.size + email_vars['current_size'] = current_size email_vars['difference'] = difference email_vars['used_percentage'] = used_percentage diff --git a/coldfront/core/utils/mail.py b/coldfront/core/utils/mail.py index 5a653f7d9..977ac188b 100644 --- a/coldfront/core/utils/mail.py +++ b/coldfront/core/utils/mail.py @@ -106,11 +106,12 @@ def send_allocation_admin_email( url_path = reverse('allocation-request-list') url = build_link(url_path, domain_url=domain_url) - pi_name = f'{allocation_obj.project.pi.first_name} {allocation_obj.project.pi.last_name} ({allocation_obj.project.pi.username})' + pi_name = f'{allocation_obj.project.pi.first_name} {allocation_obj.project.pi.last_name}' resource_name = allocation_obj.get_parent_resource ctx = email_template_context() - ctx['pi'] = pi_name + ctx['pi_name'] = pi_name + ctx['pi_username'] = f'{allocation_obj.project.pi.username}' ctx['resource'] = resource_name ctx['url'] = url if other_vars: diff --git a/coldfront/templates/email/allocation_renewed.txt b/coldfront/templates/email/allocation_renewed.txt index c08a1cf0c..4671c63fa 100644 --- a/coldfront/templates/email/allocation_renewed.txt +++ b/coldfront/templates/email/allocation_renewed.txt @@ -1,2 +1,3 @@ -A allocation has been renewed for {{pi}} - {{resource}}. Please activate the allocation: +A allocation has been renewed for {{pi_name}} ({{pi_username}}) - {{resource}}. +Please activate the allocation: {{url}} diff --git a/coldfront/templates/email/new_allocation_change_request.txt b/coldfront/templates/email/new_allocation_change_request.txt index 2a2fc1003..2feed9f94 100644 --- a/coldfront/templates/email/new_allocation_change_request.txt +++ b/coldfront/templates/email/new_allocation_change_request.txt @@ -1,5 +1,5 @@ {% load mathfilters %} -An allocation change request for has been made for {{pi}} - {{resource}}. +An allocation change request for has been made for {{pi_name}} ({{pi_username}}) - {{resource}}. {% if quantity %} Requested total size: {{quantity}} TB. @@ -11,14 +11,14 @@ This will require adding {{difference|floatformat}} TB to the current size of {{ {% endif %} {% if nese %} -Here is a draft ticket to send to NESE: +Here is a draft ticket to send to NESE. Please carefully check the values to ensure their accuracy. To: help@nese.mghpcc.org Subject: TB Globus tape setup for HU -Service (access type) = S3 vs Globus: -If Globus, short description for Globus Share: -Tennant name (8 char max - Ex. acohen): {{pi.username}} +Service (access type) = S3 vs Globus: Globus +If Globus, short description for Globus Share: {{pi_name}} +Tennant name (11 char max - Ex. acohen): {{pi_username}} Size in 20TB allotments: {{quantity|div:19.48|floatformat:"0"}} (This is a difference of {{difference|div:19.48|floatformat:"0"}} 20TB units from the current size of {{current_size|div:19.48|floatformat:"0"}} 20TB units) Any additional details: Any additional administrators (if applicable): diff --git a/coldfront/templates/email/new_allocation_request.txt b/coldfront/templates/email/new_allocation_request.txt index 1b280e49f..8c09761d3 100644 --- a/coldfront/templates/email/new_allocation_request.txt +++ b/coldfront/templates/email/new_allocation_request.txt @@ -1,5 +1,5 @@ {% load mathfilters %} -A new allocation has been requested for {{pi}} - {{resource}}. +A new allocation has been requested for {{pi_name}} ({{pi_username}}) - {{resource}}. Requested size: {{quantity}} TB. Justification: {{justification}} @@ -14,9 +14,9 @@ Here is a draft ticket to send to NESE: To: help@nese.mghpcc.org Subject: TB Globus tape setup for HU -Service (access type) = S3 vs Globus: -If Globus, short description for Globus Share: -Tennant name (8 char max - Ex. acohen): {{pi.username}} +Service (access type) = S3 vs Globus: Globus +If Globus, short description for Globus Share: {{pi_name}} +Tennant name (8 char max - Ex. acohen): {{pi_username}} Size in 20TB allotments: {{quantity|div:19.48|floatformat:"0"}} Any additional details: Any additional administrators (if applicable):