Include year and month for Sleep and Tummy Time card filters.

This commit is contained in:
Christopher Charbonneau Wells 2017-10-05 11:17:28 -04:00
parent f567de8934
commit b12f59bc52
1 changed files with 9 additions and 3 deletions

View File

@ -80,8 +80,13 @@ def card_sleep_day(child, date=None):
"""
if not date:
date = timezone.localtime().date()
instances = Sleep.objects.filter(child=child).filter(start__day=date.day) \
| Sleep.objects.filter(child=child).filter(end__day=date.day)
instances = Sleep.objects.filter(child=child).filter(
start__year=date.year,
start__month=date.month,
start__day=date.day) | Sleep.objects.filter(child=child).filter(
end__year=date.year,
end__month=date.month,
end__day=date.day)
total = timezone.timedelta(seconds=0)
for instance in instances:
@ -129,7 +134,8 @@ def card_tummytime_day(child, date=None):
if not date:
date = timezone.localtime().date()
instances = TummyTime.objects.filter(
child=child, end__day=date.day).order_by('-end')
child=child, end__year=date.year, end__month=date.month,
end__day=date.day).order_by('-end')
stats = {
'total': timezone.timedelta(seconds=0),
'count': instances.count()