From beaf366079138fe10300dd5341821248c879cca4 Mon Sep 17 00:00:00 2001 From: Ohad Lutzky Date: Fri, 9 Jul 2021 21:45:07 +0100 Subject: [PATCH] Show duration in timeline (#247) --- core/templates/core/child_detail.html | 5 +++++ core/timeline.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/templates/core/child_detail.html b/core/templates/core/child_detail.html index db32f405..f362bb51 100644 --- a/core/templates/core/child_detail.html +++ b/core/templates/core/child_detail.html @@ -62,6 +62,11 @@ {% blocktrans trimmed with since=object.time|timesince time=object.time|time %} {{ since }} ago ({{ time }}) {% endblocktrans %} + {% if object.duration %} +
+ Duration: {{ object.duration }} +
+ {% endif %} {% if object.edit_link %}
Edit diff --git a/core/timeline.py b/core/timeline.py index 4e2a8aa5..4f95e9cc 100644 --- a/core/timeline.py +++ b/core/timeline.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from django.urls import reverse -from django.utils import timezone +from django.utils import timezone, timesince from django.utils.translation import gettext as _ from core.models import DiaperChange, Feeding, Sleep, TummyTime @@ -64,6 +64,7 @@ def get_objects(child, date): }, 'details': details, 'edit_link': edit_link, + 'duration': timesince.timesince(instance.start, now=instance.end), 'model_name': instance.model_name, 'type': 'end' }) @@ -87,6 +88,7 @@ def get_objects(child, date): 'child': instance.child.first_name }, 'edit_link': edit_link, + 'duration': timesince.timesince(instance.start, now=instance.end), 'model_name': instance.model_name, 'type': 'end' }) @@ -110,6 +112,7 @@ def get_objects(child, date): 'child': instance.child.first_name }, 'edit_link': edit_link, + 'duration': timesince.timesince(instance.start, now=instance.end), 'model_name': instance.model_name, 'type': 'end' })