diff --git a/atst/routes/workspaces.py b/atst/routes/workspaces.py index ebb9375e..a49a5996 100644 --- a/atst/routes/workspaces.py +++ b/atst/routes/workspaces.py @@ -1,3 +1,5 @@ +from datetime import date, timedelta + from flask import ( Blueprint, render_template, @@ -73,10 +75,21 @@ def workspace_reports(workspace_id): ): raise UnauthorizedError(g.current_user, "view workspace reports") + alternate_reports = http_request.args.get('alternate') + month = http_request.args.get('month', 3) + year = http_request.args.get('year', 2019) + current_month = date(int(year), int(month), 15) + prev_month = current_month - timedelta(days=28) + two_months_ago = prev_month - timedelta(days=28) + + return render_template( "workspace_reports.html", - workspace_totals=Reports.workspace_totals(workspace), - monthly_totals=Reports.monthly_totals(workspace), + workspace_totals=Reports.workspace_totals(alternate_reports), + monthly_totals=Reports.monthly_totals(alternate_reports), + current_month=current_month, + prev_month=prev_month, + two_months_ago=two_months_ago, ) diff --git a/templates/workspace_reports.html b/templates/workspace_reports.html index 0d08322d..060f33e8 100644 --- a/templates/workspace_reports.html +++ b/templates/workspace_reports.html @@ -89,37 +89,37 @@ - {% set current_month = '03/2019' %} - {% set prev_month = '02/2019' %} - {% set two_months_ago = '01/2019' %} {% set workspace_totals = monthly_totals['workspace'] %} + {% set current_month_index = current_month.strftime('%m/%Y') %} + {% set prev_month_index = prev_month.strftime('%m/%Y') %} + {% set two_months_ago_index = two_months_ago.strftime('%m/%Y') %}

Total spend per month

- - - + + + - - - + + + @@ -135,21 +135,21 @@ {{ project_name }} - - - + + + {% for env_name, env_totals in monthly_totals['environments'][project_name].items() %} - - - + + + {% endfor %}
Spending scopeJanuary 2019February 2019March 2019{{ two_months_ago.strftime('%B %Y') }}{{ prev_month.strftime('%B %Y') }}{{ current_month.strftime('%B %Y') }}
Workspace Total{{ workspace_totals.get(two_months_ago, 0) | dollars }}{{ workspace_totals.get(prev_month, 0) | dollars }}{{ workspace_totals.get(current_month, 0) | dollars }}{{ workspace_totals.get(two_months_ago_index, 0) | dollars }}{{ workspace_totals.get(prev_month_index, 0) | dollars }}{{ workspace_totals.get(current_month_index, 0) | dollars }} - +
{{ project_totals.get(two_months_ago, 0) | dollars }}{{ project_totals.get(prev_month, 0) | dollars }}{{ project_totals.get(current_month, 0) | dollars }}{{ project_totals.get(two_months_ago_index, 0) | dollars }}{{ project_totals.get(prev_month_index, 0) | dollars }}{{ project_totals.get(current_month_index, 0) | dollars }} - {{ (100 * (project_totals.get(current_month, 0) / workspace_totals.get(current_month, 1))) | round | int }}% - + {{ (100 * (project_totals.get(current_month_index, 0) / workspace_totals.get(current_month_index, 1))) | round | int }}% +
{{ Icon('link') }} {{ env_name }}{{ env_totals.get(two_months_ago, 0) | dollars }}{{ env_totals.get(prev_month, 0) | dollars }}{{ env_totals.get(current_month, 0) | dollars }}{{ env_totals.get(two_months_ago_index, 0) | dollars }}{{ env_totals.get(prev_month_index, 0) | dollars }}{{ env_totals.get(current_month_index, 0) | dollars }}