Skip to content

Commit

Permalink
improve nese ticket generation
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Oct 31, 2023
1 parent dce6997 commit a20f84b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
13 changes: 9 additions & 4 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,14 +2049,17 @@ 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

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}))
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions coldfront/core/utils/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion coldfront/templates/email/allocation_renewed.txt
Original file line number Diff line number Diff line change
@@ -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}}
10 changes: 5 additions & 5 deletions coldfront/templates/email/new_allocation_change_request.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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: [email protected]
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):
Expand Down
8 changes: 4 additions & 4 deletions coldfront/templates/email/new_allocation_request.txt
Original file line number Diff line number Diff line change
@@ -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}}
Expand All @@ -14,9 +14,9 @@ Here is a draft ticket to send to NESE:
To: [email protected]
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):
Expand Down

0 comments on commit a20f84b

Please sign in to comment.