Skip to content

Commit a20f84b

Browse files
committed
improve nese ticket generation
1 parent dce6997 commit a20f84b

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

coldfront/core/allocation/views.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,14 +2049,17 @@ def post(self, request, *args, **kwargs):
20492049

20502050
if form_data.get('end_date_extension') != 0:
20512051
change_requested = True
2052+
2053+
# if requested resource is on NESE, add to vars
2054+
nese = bool(allocation_obj.resources.filter(name__contains="nesetape"))
2055+
20522056
if attrs_to_change:
20532057
for entry in formset:
20542058
formset_data = entry.cleaned_data
20552059

20562060
new_value = formset_data.get('new_value')
20572061
# require nese shares to be divisible by 20
20582062
tbs = int(new_value) if formset_data['name'] == 'Storage Quota (TB)' else False
2059-
nese = bool(allocation_obj.resources.filter(name__contains="nesetape"))
20602063
if nese and tbs and tbs % 20 != 0:
20612064
messages.error(request, "Tier 3 quantity must be a multiple of 20.")
20622065
return HttpResponseRedirect(reverse('allocation-change', kwargs={'pk': pk}))
@@ -2097,17 +2100,19 @@ def post(self, request, *args, **kwargs):
20972100
for a in attribute_changes_to_make
20982101
if a[0].allocation_attribute_type.name == 'Storage Quota (TB)'
20992102
]
2100-
# if requested resource is on NESE, add to vars
2101-
nese = bool(allocation_obj.resources.filter(name__contains="nesetape"))
21022103

21032104
email_vars = {'justification': justification}
21042105
if quantity:
21052106
quantity_num = int(float(quantity[0][1]))
21062107
difference = quantity_num - int(float(allocation_obj.size))
21072108
used_percentage = allocation_obj.get_parent_resource.used_percentage
2109+
current_size = allocation_obj.size
2110+
if nese:
2111+
current_size = round(current_size, -1)
2112+
difference = round(difference, -1)
21082113
email_vars['quantity'] = quantity_num
21092114
email_vars['nese'] = nese
2110-
email_vars['current_size'] = allocation_obj.size
2115+
email_vars['current_size'] = current_size
21112116
email_vars['difference'] = difference
21122117
email_vars['used_percentage'] = used_percentage
21132118

coldfront/core/utils/mail.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ def send_allocation_admin_email(
106106
url_path = reverse('allocation-request-list')
107107

108108
url = build_link(url_path, domain_url=domain_url)
109-
pi_name = f'{allocation_obj.project.pi.first_name} {allocation_obj.project.pi.last_name} ({allocation_obj.project.pi.username})'
109+
pi_name = f'{allocation_obj.project.pi.first_name} {allocation_obj.project.pi.last_name}'
110110
resource_name = allocation_obj.get_parent_resource
111111

112112
ctx = email_template_context()
113-
ctx['pi'] = pi_name
113+
ctx['pi_name'] = pi_name
114+
ctx['pi_username'] = f'{allocation_obj.project.pi.username}'
114115
ctx['resource'] = resource_name
115116
ctx['url'] = url
116117
if other_vars:
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
A allocation has been renewed for {{pi}} - {{resource}}. Please activate the allocation:
1+
A allocation has been renewed for {{pi_name}} ({{pi_username}}) - {{resource}}.
2+
Please activate the allocation:
23
{{url}}

coldfront/templates/email/new_allocation_change_request.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% load mathfilters %}
2-
An allocation change request for has been made for {{pi}} - {{resource}}.
2+
An allocation change request for has been made for {{pi_name}} ({{pi_username}}) - {{resource}}.
33

44
{% if quantity %}
55
Requested total size: {{quantity}} TB.
@@ -11,14 +11,14 @@ This will require adding {{difference|floatformat}} TB to the current size of {{
1111
{% endif %}
1212

1313
{% if nese %}
14-
Here is a draft ticket to send to NESE:
14+
Here is a draft ticket to send to NESE. Please carefully check the values to ensure their accuracy.
1515

1616
To: help@nese.mghpcc.org
1717
Subject: TB Globus tape setup for HU
1818

19-
Service (access type) = S3 vs Globus:
20-
If Globus, short description for Globus Share:
21-
Tennant name (8 char max - Ex. acohen): {{pi.username}}
19+
Service (access type) = S3 vs Globus: Globus
20+
If Globus, short description for Globus Share: {{pi_name}}
21+
Tennant name (11 char max - Ex. acohen): {{pi_username}}
2222
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)
2323
Any additional details:
2424
Any additional administrators (if applicable):

coldfront/templates/email/new_allocation_request.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% load mathfilters %}
2-
A new allocation has been requested for {{pi}} - {{resource}}.
2+
A new allocation has been requested for {{pi_name}} ({{pi_username}}) - {{resource}}.
33
Requested size: {{quantity}} TB.
44
Justification:
55
{{justification}}
@@ -14,9 +14,9 @@ Here is a draft ticket to send to NESE:
1414
To: help@nese.mghpcc.org
1515
Subject: TB Globus tape setup for HU
1616

17-
Service (access type) = S3 vs Globus:
18-
If Globus, short description for Globus Share:
19-
Tennant name (8 char max - Ex. acohen): {{pi.username}}
17+
Service (access type) = S3 vs Globus: Globus
18+
If Globus, short description for Globus Share: {{pi_name}}
19+
Tennant name (8 char max - Ex. acohen): {{pi_username}}
2020
Size in 20TB allotments: {{quantity|div:19.48|floatformat:"0"}}
2121
Any additional details:
2222
Any additional administrators (if applicable):

0 commit comments

Comments
 (0)