Add time progress template
This commit is contained in:
parent
df26c50e12
commit
cb057e7ee7
3 changed files with 60 additions and 0 deletions
|
|
@ -80,6 +80,31 @@ class Government(models.Model):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def days_available(self):
|
||||
if self.start_date is None:
|
||||
return 0
|
||||
if self.end_date is None:
|
||||
return 0
|
||||
return (self.end_date - self.start_date).days
|
||||
|
||||
@property
|
||||
def days_left(self):
|
||||
if not self.end_date:
|
||||
return 0
|
||||
now = timezone.now().date()
|
||||
if now > self.end_date:
|
||||
return 0
|
||||
return (self.end_date - now).days
|
||||
|
||||
def days_used_percentage(self) -> int:
|
||||
total_days = self.days_available
|
||||
if not total_days:
|
||||
return 0
|
||||
now = timezone.now().date()
|
||||
days_used = (now - self.start_date).days
|
||||
return int(days_used / total_days * 100)
|
||||
|
||||
|
||||
class CategorizedGovernmentPlan(TaggedItemBase):
|
||||
tag = models.ForeignKey(
|
||||
|
|
@ -442,6 +467,8 @@ if CMSPlugin:
|
|||
PLUGIN_TEMPLATES = [
|
||||
("froide_govplan/plugins/default.html", _("Normal")),
|
||||
("froide_govplan/plugins/progress.html", _("Progress")),
|
||||
("froide_govplan/plugins/progress_row.html", _("Progress Row")),
|
||||
("froide_govplan/plugins/time_used.html", _("Time used")),
|
||||
("froide_govplan/plugins/card_cols.html", _("Card columns")),
|
||||
("froide_govplan/plugins/search.html", _("Search")),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
{% load govplan %}
|
||||
|
||||
{% get_plan_progress object_list as progress %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<span class="text-gray-700{% if not instance.extra_classes or "progress-lg" not in instance.extra_classes %} small{% endif %}">{{ progress.count }} Vorhaben</span>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="progress" {% if "progress-lg" in instance.extra_classes %}style="height: 1.5rem;"{% endif %}>
|
||||
{% 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" aria-label="{{ section.percentage }}% {{ section.label }}" title="{{ section.percentage }}% {{ section.label }}" data-bs-toggle="tooltip" data-placement="top">
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{% load govplan %}
|
||||
|
||||
<div class="row">
|
||||
{% with gov=instance.government %}
|
||||
<div class="col-sm-3">
|
||||
<span class="text-gray-700">{{ gov.days_left }} Tage übrig</span>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="progress" style="height: 1.5rem;">
|
||||
<div class="progress-bar bg-secondary" role="progressbar" style="width: {{ gov.days_used_percentage }}%;" aria-valuenow="{{ gov.days_used_percentage }}" aria-valuemin="0" aria-valuemax="100" aria-label="{{ gov.days_used_percentage }}%" title="{{ gov.days_used_percentage }}%" data-bs-toggle="tooltip" data-placement="top">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue