From 22b7874593fa713d216db26a6c08f715854ce20a Mon Sep 17 00:00:00 2001 From: krmax44 Date: Fri, 11 Mar 2022 14:27:16 +0100 Subject: [PATCH] wip: add context to progress bar --- froide_govplan/models.py | 2 +- .../froide_govplan/plugins/progress.html | 15 +++++++++------ froide_govplan/templatetags/govplan.py | 4 +++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/froide_govplan/models.py b/froide_govplan/models.py index e5f6f59..97dc7a9 100644 --- a/froide_govplan/models.py +++ b/froide_govplan/models.py @@ -28,7 +28,7 @@ class PlanStatus(models.TextChoices): STATUS_CSS = { - PlanStatus.NOT_STARTED: "secondary", + PlanStatus.NOT_STARTED: "light", PlanStatus.STARTED: "primary", PlanStatus.PARTIALLY_IMPLEMENTED: "warning", PlanStatus.IMPLEMENTED: "success", diff --git a/froide_govplan/templates/froide_govplan/plugins/progress.html b/froide_govplan/templates/froide_govplan/plugins/progress.html index c4ce7d5..b74afca 100644 --- a/froide_govplan/templates/froide_govplan/plugins/progress.html +++ b/froide_govplan/templates/froide_govplan/plugins/progress.html @@ -2,12 +2,15 @@ {% get_plan_progress object_list as progress %} -
-
- {% for section in progress.sections %} -
-
- {% endfor %} +
+ {{ progress.count }} Vorhaben +
+
+ {% for section in progress.sections %} +
+
+ {% endfor %} +
diff --git a/froide_govplan/templatetags/govplan.py b/froide_govplan/templatetags/govplan.py index e1a8e05..cff6db0 100644 --- a/froide_govplan/templatetags/govplan.py +++ b/froide_govplan/templatetags/govplan.py @@ -10,7 +10,9 @@ def get_plan_progress(object_list): sections = [] for value, label in PlanStatus.choices: status_count = len([x for x in object_list if x.status == value]) - percentage = status_count / len(object_list) * 100 + percentage = ( + 0 if len(object_list) == 0 else status_count / len(object_list) * 100 + ) sections.append( { "count": status_count,