Do not set default init date in Tummy Time card declaration.

This would cause the date to default to the date the instance starts, not the date the method is called from a template.
This commit is contained in:
Christopher Charbonneau Wells 2017-09-07 20:12:36 -04:00
parent 422b381e50
commit 89e60e46b7
1 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django import template from django import template
from django.utils import formats, timezone from django.utils import timezone
from core.models import DiaperChange, Feeding, Sleep, TummyTime from core.models import DiaperChange, Feeding, Sleep, TummyTime
@ -75,9 +75,11 @@ def card_tummytime_last(child):
@register.inclusion_tag('cards/tummytime_day.html') @register.inclusion_tag('cards/tummytime_day.html')
def card_tummytime_day(child, date=timezone.localtime().date()): def card_tummytime_day(child, date=None):
"""Tummy time over the course of `date`. """Tummy time over the course of `date`.
""" """
if not date:
date = timezone.localtime().date()
instances = TummyTime.objects.filter( instances = TummyTime.objects.filter(
child=child, end__day=date.day).order_by('-end') child=child, end__day=date.day).order_by('-end')
stats = { stats = {