wip: add context to progress bar

This commit is contained in:
krmax44 2022-03-11 14:27:16 +01:00
parent e24349b9de
commit 22b7874593
No known key found for this signature in database
GPG key ID: 5C499A4F4EC4EE03
3 changed files with 13 additions and 8 deletions

View file

@ -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",

View file

@ -2,12 +2,15 @@
{% get_plan_progress object_list as progress %}
<div>
<div class="progress" style="height: 25px;">
{% for section in progress.sections %}
<div class="progress-bar bg-{{ section.css_class }}" role="progressbar" style="width: {{ section.css_percentage }}%;" aria-valuenow="{{ section.css_percentage }}" aria-valuemin="0" aria-valuemax="100" title="{{ section.label }}: {{ section.percentage }}%" data-toggle="tooltip" data-placement="top">
</div>
{% endfor %}
<div class="d-flex align-items-center">
<small class="text-gray-700">{{ progress.count }} Vorhaben</small>
<div class="flex-grow-1 ml-2">
<div class="progress">
{% for section in progress.sections %}
<div class="progress-bar bg-{{ section.css_class }}" role="progressbar" style="width: {{ section.css_percentage }}%;" aria-valuenow="{{ section.css_percentage }}" aria-valuemin="0" aria-valuemax="100" title="{{ section.percentage }}% {{ section.label }}" data-toggle="tooltip" data-placement="top">
</div>
{% endfor %}
</div>
</div>
</div>

View file

@ -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,