Skip to content

Commit 36b0b2a

Browse files
committedNov 4, 2019
Pushing changes to github to handle Dean's allocation approval in part
response with comments and SU approavl count
1 parent ac126de commit 36b0b2a

File tree

2 files changed

+85
-4
lines changed

2 files changed

+85
-4
lines changed
 
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{% extends "base_email.html" %} {% block content %}
2+
<p
3+
style="font-family: sans-serif; font-size: 16px; font-weight: bold; margin: 0; Margin-bottom: 15px;"
4+
>
5+
{{ confirmation_str }}
6+
</p>
7+
<form
8+
action="{{ confirm_part_approve_url }}"
9+
method="post"
10+
id="allocation-form"
11+
accept-charset="UTF-8"
12+
>
13+
<table border="0" cellpadding="0" cellspacing="5">
14+
<tbody>
15+
<tr>
16+
<td>
17+
<div class="col form-item form-type-textfield form-group">
18+
<label
19+
>Total approved SUs
20+
<span class="form-required" title="This field is required."
21+
>*</span
22+
></label
23+
>
24+
<input
25+
required="required"
26+
type="number"
27+
id="su-request-approved-by-dean"
28+
name="su-request-approved-by-dean"
29+
value=""
30+
size="20"
31+
maxlength="20"
32+
/>
33+
</div>
34+
<div class="spacer-20"></div>
35+
<div class="form-item form-type-textarea form-group">
36+
<p style="font-size:85%;font-color:#bbb;">
37+
In the box below, please briefly explain why this allocation
38+
request is only approved in part (optional).
39+
</p>
40+
<div class="form-textarea-wrapper resizable">
41+
<textarea
42+
required="required"
43+
class="form-control form-textarea required"
44+
id="deans-explanation"
45+
name="deans-explanation"
46+
cols="60"
47+
rows="12"
48+
></textarea>
49+
</div>
50+
</div>
51+
</td>
52+
</tr>
53+
<tr>
54+
<td>
55+
<button
56+
style="align: center; display: inline-block; width: 180px; color: #0a0a0a; background-color: #f37209; border: solid 1px #42BD41; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 10px; font-weight: bold; margin: 0; padding: 10px 20px; text-transform: capitalize; border-color: #FCE903;"
57+
id="submit"
58+
type="submit"
59+
>
60+
Submit Confirmation
61+
</button>
62+
</td>
63+
</tr>
64+
</tbody>
65+
</table>
66+
</form>
67+
{% endblock %}

‎app/views.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,32 @@ def hpc_allocation_request():
163163
'request: {}'.format(str(ex))]))
164164

165165

166-
@app.route('/rest/confirm-hpc-allocation-request/<token>/', methods=['GET'])
167-
@limiter.limit("6 per hour")
168-
@limiter.limit("1 per minute")
166+
@app.route('/rest/confirm-hpc-allocation-request/<token>/', methods=['GET', 'POST'])
167+
@limiter.limit("12 per hour")
168+
@limiter.limit("4 per minute")
169169
def confirm_hpc_allocation_request(token):
170170
try:
171171
for salt_str in ALLOC_APPROVE_CONFIRM_TYPES:
172172
sig_okay, ticket_id = URLSafeTimedSerializer(
173173
app.config["MAIL_SECRET_KEY"]
174174
).loads_unsafe(token, salt=salt_str, max_age=1209600)
175175
if (sig_okay):
176+
if(salt_str == ALLOC_APPROVE_CONFIRM_TYPES[2] and request.environ['REQUEST_METHOD'] == 'GET'):
177+
return render_template(
178+
'confirm_explanation.html',
179+
logo_url=RC_SMALL_LOGO_URL,
180+
confirmation_str='{} confirmation form'.format(
181+
salt_str),
182+
confirm_approve_url=request.base_url,
183+
)
184+
comment_list = [
185+
'Confirmation received from sponsor: ', salt_str.upper()]
186+
if(salt_str == ALLOC_APPROVE_CONFIRM_TYPES[2] and request.environ['REQUEST_METHOD'] == 'POST'):
187+
comment_list = comment_list + ['\n\nSUs approved by sponsor: ', request.form['su-request-approved-by-dean'],
188+
'\n\nExplanation: ', request.form['deans-explanation']]
189+
176190
response = json.loads(JiraServiceHandler(
177-
app).addTicketComment(ticket_id, ''.join(['Confirmation received from sponsor: ', salt_str])))
191+
app).addTicketComment(ticket_id, ''.join(comment_list)))
178192
if ('errorMessage' in response
179193
and response['errorMessage'] is not None
180194
and response['errorMessage'] != ''):

0 commit comments

Comments
 (0)
Please sign in to comment.