diff --git a/atst/domain/reports.py b/atst/domain/reports.py index 99a913ec..15a00812 100644 --- a/atst/domain/reports.py +++ b/atst/domain/reports.py @@ -215,16 +215,18 @@ class Reports: @classmethod def monthly_totals(cls, workspace): if workspace.name in REPORT_FIXTURE_MAP: - data = REPORT_FIXTURE_MAP[workspace.name]["monthly"] - project_totals = _derive_project_totals(data) - workspace_totals = _derive_workspace_totals(project_totals) + environments = REPORT_FIXTURE_MAP[workspace.name]["monthly"] else: - data = {} - project_totals = {} - workspace_totals = {} + environments = { + project.name: {env.name: {} for env in project.environments} + for project in workspace.projects + } + + project_totals = _derive_project_totals(environments) + workspace_totals = _derive_workspace_totals(project_totals) return { - "environments": data, + "environments": environments, "projects": project_totals, "workspace": workspace_totals, } diff --git a/templates/workspaces/reports/index.html b/templates/workspaces/reports/index.html index 7df90c80..b32543d2 100644 --- a/templates/workspaces/reports/index.html +++ b/templates/workspaces/reports/index.html @@ -103,7 +103,7 @@ {% set two_months_ago_index = two_months_ago.strftime('%m/%Y') %} {% set reports_url = url_for("workspaces.workspace_reports", workspace_id=workspace.id) %} - {% if not monthly_totals['environments'] %} + {% if not workspace.projects %} {% set can_create_projects = user_can(permissions.ADD_APPLICATION_IN_WORKSPACE) %} {% set message = 'This Workspace has no Cloud Environments setup, hence there is no spending data to report. Create a Project with some Cloud Environments to get started.' @@ -335,6 +335,9 @@ {{ month.strftime('%B %Y') }} {% endfor %} + {% if not cumulative_budget["months"] %} + + {% endif %}