mirror of https://github.com/snachodog/mybuddy.git
fix #699, add diaper change count to card stats
This commit is contained in:
parent
1063d39af0
commit
3131aeb328
|
@ -49,6 +49,9 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{% blocktrans with days_ago=key %}{{ days_ago }} days ago{% endblocktrans %}
|
{% blocktrans with days_ago=key %}{{ days_ago }} days ago{% endblocktrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if info.changes > 0 %}
|
||||||
|
({{ info.changes|floatformat:'0' }} {% trans "changes" %})
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -70,7 +70,7 @@ def card_diaperchange_types(context, child, date=None):
|
||||||
)
|
)
|
||||||
|
|
||||||
for x in range(7):
|
for x in range(7):
|
||||||
stats[x] = {"wet": 0.0, "solid": 0.0, "empty": 0.0}
|
stats[x] = {"wet": 0.0, "solid": 0.0, "empty": 0.0, "changes": 0.0}
|
||||||
|
|
||||||
instances = (
|
instances = (
|
||||||
models.DiaperChange.objects.filter(child=child)
|
models.DiaperChange.objects.filter(child=child)
|
||||||
|
@ -82,6 +82,7 @@ def card_diaperchange_types(context, child, date=None):
|
||||||
|
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
key = (max_date - instance.time).days
|
key = (max_date - instance.time).days
|
||||||
|
stats[key]["changes"] += 1
|
||||||
if instance.wet:
|
if instance.wet:
|
||||||
stats[key]["wet"] += 1
|
stats[key]["wet"] += 1
|
||||||
if instance.solid:
|
if instance.solid:
|
||||||
|
|
Loading…
Reference in New Issue