Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[batch] Separate closed and open projects on billing limits page #13215

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion batch/batch/front_end/front_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,14 @@ async def ui_get_billing_limits(request, userdata):

billing_projects = await query_billing_projects(db, user=user)

page_context = {'billing_projects': billing_projects, 'is_developer': userdata['is_developer']}
open_billing_projects = [bp for bp in billing_projects if bp['status'] == 'open']
closed_billing_projects = [bp for bp in billing_projects if bp['status'] == 'closed']

page_context = {
'open_billing_projects': open_billing_projects,
'closed_billing_projects': closed_billing_projects,
'is_developer': userdata['is_developer'],
}
return await render_template('batch', request, userdata, 'billing_limits.html', page_context)


Expand Down
42 changes: 40 additions & 2 deletions batch/batch/front_end/templates/billing_limits.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
{% block title %}Billing Limits{% endblock %}
{% block content %}
<h1>Billing Project Limits</h1>
{% if open_billing_projects %}
<div class='flex-col' style="overflow: auto;">
<table class="data-table" id="billing_limits">
<h2>Open Projects</h2>
<table class="data-table" id="open-billing-limits">
<thead>
<tr>
<th>Billing Project</th>
Expand All @@ -12,7 +14,7 @@ <h1>Billing Project Limits</h1>
</tr>
</thead>
<tbody>
{% for row in billing_projects %}
{% for row in open_billing_projects %}
<tr>
<td>{{ row['billing_project'] }}</td>
<td>{{ row['accrued_cost'] }}</td>
Expand All @@ -34,4 +36,40 @@ <h1>Billing Project Limits</h1>
</tbody>
</table>
</div>
{% endif %}
{% if closed_billing_projects %}
<div class='flex-col' style="overflow: auto;">
<h2>Closed Projects</h2>
<table class="data-table" id="closed-billing-limits">
<thead>
<tr>
<th>Billing Project</th>
<th>Accrued Cost</th>
<th>Limit</th>
</tr>
</thead>
<tbody>
{% for row in closed_billing_projects %}
<tr>
<td>{{ row['billing_project'] }}</td>
<td>{{ row['accrued_cost'] }}</td>
{% if is_developer %}
<td>
<form action="{{ base_path }}/billing_limits/{{ row['billing_project'] }}/edit" method="POST">
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
<input type="text" required name="limit" value="{{ row['limit'] }}">
<button>
Edit
</button>
</form>
</td>
{% else %}
<td>{{ row['limit'] }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endblock %}