From 634ca1c76ddee64a5fd72db0e5567becbe3eb6a2 Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 24 Sep 2018 16:28:22 -0400 Subject: [PATCH 1/3] always return project and envs for reports page and check if workspace has projects --- atst/domain/reports.py | 16 +++++++++------- templates/workspaces/reports/index.html | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) 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 82bc92cf..dac32622 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.' From 90674b2e620c5b815b8ca02d292ea0243e608d75 Mon Sep 17 00:00:00 2001 From: dandds Date: Tue, 25 Sep 2018 09:00:20 -0400 Subject: [PATCH 2/3] return current month with no data for cumulative budget report --- atst/domain/reports.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atst/domain/reports.py b/atst/domain/reports.py index 15a00812..23f3860c 100644 --- a/atst/domain/reports.py +++ b/atst/domain/reports.py @@ -1,3 +1,4 @@ +from datetime import datetime from itertools import groupby @@ -236,6 +237,7 @@ class Reports: if workspace.name in REPORT_FIXTURE_MAP: months = REPORT_FIXTURE_MAP[workspace.name]["cumulative"] else: - months = {} + this_month = datetime.today().strftime("%m/%Y") + months = {this_month: {"spend": 0, "cumulative": 0}} return {"months": months} From 3c7b5a083d5a70115a715376159c0de1358cc897 Mon Sep 17 00:00:00 2001 From: dandds Date: Tue, 25 Sep 2018 13:20:15 -0400 Subject: [PATCH 3/3] always display at least current month on reports select menu --- atst/domain/reports.py | 4 +--- templates/workspaces/reports/index.html | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/atst/domain/reports.py b/atst/domain/reports.py index 23f3860c..15a00812 100644 --- a/atst/domain/reports.py +++ b/atst/domain/reports.py @@ -1,4 +1,3 @@ -from datetime import datetime from itertools import groupby @@ -237,7 +236,6 @@ class Reports: if workspace.name in REPORT_FIXTURE_MAP: months = REPORT_FIXTURE_MAP[workspace.name]["cumulative"] else: - this_month = datetime.today().strftime("%m/%Y") - months = {this_month: {"spend": 0, "cumulative": 0}} + months = {} return {"months": months} diff --git a/templates/workspaces/reports/index.html b/templates/workspaces/reports/index.html index dac32622..9c74f8ba 100644 --- a/templates/workspaces/reports/index.html +++ b/templates/workspaces/reports/index.html @@ -335,6 +335,9 @@ {{ month.strftime('%B %Y') }} {% endfor %} + {% if not cumulative_budget["months"] %} + + {% endif %}