Show feeding amount on timeline

This commit is contained in:
Ohad Lutzky 2021-07-02 20:30:51 +01:00 committed by Christopher Charbonneau Wells
parent ed1d6b779e
commit e3b6f79c09
2 changed files with 11 additions and 1 deletions

View File

@ -52,7 +52,10 @@
</div>
<div class="card text-right">
<div class="card-body">
{{ object.event }}
{{ object.event }}<br />
{% if object.details %}
<small>{{ object.details }}</small>
{% endif %}
</div>
<div class="card-footer text-muted">
{% blocktrans trimmed with since=object.time|timesince time=object.time|time %}

View File

@ -30,11 +30,17 @@ def get_objects(child, date):
instances = Feeding.objects.filter(child=child).filter(
start__range=(min_date, max_date)).order_by('-start')
for instance in instances:
details = None
if instance.amount:
details = _('Amount: %(amount).0f') % {
'amount': instance.amount,
}
events.append({
'time': timezone.localtime(instance.start),
'event': _('%(child)s started feeding.') % {
'child': instance.child.first_name
},
'details': details,
'model_name': instance.model_name,
'type': 'start'
})
@ -43,6 +49,7 @@ def get_objects(child, date):
'event': _('%(child)s finished feeding.') % {
'child': instance.child.first_name
},
'details': details,
'model_name': instance.model_name,
'type': 'end'
})