Show duration in timeline (#247)

This commit is contained in:
Ohad Lutzky 2021-07-09 21:45:07 +01:00 committed by GitHub
parent dd3aa3bdb8
commit beaf366079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -62,6 +62,11 @@
{% blocktrans trimmed with since=object.time|timesince time=object.time|time %} {% blocktrans trimmed with since=object.time|timesince time=object.time|time %}
{{ since }} ago ({{ time }}) {{ since }} ago ({{ time }})
{% endblocktrans %} {% endblocktrans %}
{% if object.duration %}
<div>
<small>Duration: {{ object.duration }}</small>
</div>
{% endif %}
{% if object.edit_link %} {% if object.edit_link %}
<div> <div>
<small><a href="{{ object.edit_link }}">Edit</a></small> <small><a href="{{ object.edit_link }}">Edit</a></small>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.urls import reverse from django.urls import reverse
from django.utils import timezone from django.utils import timezone, timesince
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from core.models import DiaperChange, Feeding, Sleep, TummyTime from core.models import DiaperChange, Feeding, Sleep, TummyTime
@ -64,6 +64,7 @@ def get_objects(child, date):
}, },
'details': details, 'details': details,
'edit_link': edit_link, 'edit_link': edit_link,
'duration': timesince.timesince(instance.start, now=instance.end),
'model_name': instance.model_name, 'model_name': instance.model_name,
'type': 'end' 'type': 'end'
}) })
@ -87,6 +88,7 @@ def get_objects(child, date):
'child': instance.child.first_name 'child': instance.child.first_name
}, },
'edit_link': edit_link, 'edit_link': edit_link,
'duration': timesince.timesince(instance.start, now=instance.end),
'model_name': instance.model_name, 'model_name': instance.model_name,
'type': 'end' 'type': 'end'
}) })
@ -110,6 +112,7 @@ def get_objects(child, date):
'child': instance.child.first_name 'child': instance.child.first_name
}, },
'edit_link': edit_link, 'edit_link': edit_link,
'duration': timesince.timesince(instance.start, now=instance.end),
'model_name': instance.model_name, 'model_name': instance.model_name,
'type': 'end' 'type': 'end'
}) })