mirror of https://github.com/snachodog/mybuddy.git
Use a timedelta for last tummy time card.
This commit is contained in:
parent
f81f763cfb
commit
591f2fba52
|
@ -1,9 +1,10 @@
|
|||
{% extends 'cards/tummytime.html' %}
|
||||
{% load duration %}
|
||||
|
||||
{% block header %}Today's Tummy Time{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
<strong>{{ stats.total }}</strong> seconds
|
||||
<strong>{{ stats.total|duration_string }}</strong>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -13,7 +14,7 @@
|
|||
{% block listgroup %}
|
||||
<ul class="list-group list-group-flush text-muted small">
|
||||
{% for instance in instances %}
|
||||
<li class="list-group-item">{{ instance.duration }} at {{ instance.end|time }}</li>
|
||||
<li class="list-group-item">{{ instance.duration|duration_string }} at {{ instance.end|time }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from collections import OrderedDict
|
||||
from datetime import timedelta
|
||||
|
||||
from django import template
|
||||
from django.utils import timezone
|
||||
|
@ -59,9 +60,9 @@ def card_tummytime_last(child):
|
|||
def card_tummytime_day(child, date=timezone.now().date()):
|
||||
instances = TummyTime.objects.filter(
|
||||
child=child, end__day=date.day).order_by('-end')
|
||||
stats = {'total': 0, 'count': instances.count()}
|
||||
stats = {'total': timedelta(seconds=0), 'count': instances.count()}
|
||||
for instance in instances:
|
||||
stats['total'] += instance.duration_td().seconds
|
||||
stats['total'] += timedelta(seconds=instance.duration_td().seconds)
|
||||
return {'stats': stats, 'instances': instances, 'last': instances.first()}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue