Skip to content

Commit

Permalink
fix project total usage table
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Dec 1, 2023
1 parent 61990b0 commit a756bef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions coldfront/core/project/templates/project/project_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ <h3 class="d-inline"><i class="fas fa-file-invoice-dollar" aria-hidden="true"></
<tfoot>
<tr style="background-color:#C2C2C2;font-weight:bold">
<td>Total</td>
<td>{{ allocation_total.resources.first.name}}</td>
<td>{{ allocation_total.path}}</td>
<td>{{ allocation_total.allocation_user_count}}</td>
<td>{{ allocation_total.size|floatformat:1}}</td>
<td>${{allocation_total.cost|floatformat:2 }}</td>
<td>{{ allocation_total.resources.first.name }}</td>
<td>{{ allocation_total.path }}</td>
<td>{{ allocation_total.allocation_user_count }}</td>
<td>{{ allocation_total.size|floatformat:1 }}</td>
<td>{{ allocation_total.usage|floatformat:1 }}</td>
<td>${{ allocation_total.cost|floatformat:2 }}</td>
<td></td>
<td></td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,15 @@ def get_context_data(self, **kwargs):
allocations = allocations.filter(
status__name__in=['Active', 'Paid', 'Ready for Review','Payment Requested']
).distinct().order_by('-end_date')
allocation_total = {'allocation_user_count': 0, 'size': 0, 'cost': 0}
allocation_total = {'allocation_user_count': 0, 'size': 0, 'cost': 0, 'usage': 0}
for allocation in allocations:
if allocation.cost:
allocation_total['cost'] += allocation.cost
allocation_total['allocation_user_count'] += int(
allocation.allocationuser_set.count()
)
allocation_total['size'] += float(allocation.size)
allocation_total['usage'] += float(allocation.usage)

try:
time_chart_data = generate_usage_history_graph(self.object)
Expand Down

0 comments on commit a756bef

Please sign in to comment.