Add last Sleep and Tummy Time cards and change to a card columns layout.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-18 11:22:08 -04:00
parent e92050cb44
commit 63faa0b553
6 changed files with 81 additions and 29 deletions

View File

@ -0,0 +1,13 @@
<div class="card border-dark mb-3">
<div class="card-header text-white bg-dark h4">
<i class="fa fa-bed pull-left" aria-hidden="true"></i>
{% block header %}{% endblock %}
</div>
<div class="card-body text-dark">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<div class="card-text">{% block content %}{% endblock %}</div>
</div>
<div class="card-footer text-muted">
{% block footer %}{% endblock %}
</div>
</div>

View File

@ -0,0 +1,15 @@
{% extends 'cards/sleep.html' %}
{% block header %}Last Slept{% endblock %}
{% block title %}
<strong>{{ sleep.end|timesince }}</strong> ago
{% endblock %}
{% block content %}
<div class="text-muted">
{{ sleep.duration }}
</div>
{% endblock %}
{% block footer %}{{ sleep.end }}{% endblock %}

View File

@ -0,0 +1,13 @@
<div class="card border-success mb-3">
<div class="card-header text-white bg-success h4">
<i class="fa fa-smile-o pull-left" aria-hidden="true"></i>
{% block header %}{% endblock %}
</div>
<div class="card-body text-success">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<div class="card-text">{% block content %}{% endblock %}</div>
</div>
<div class="card-footer text-muted">
{% block footer %}{% endblock %}
</div>
</div>

View File

@ -0,0 +1,18 @@
{% extends 'cards/tummytime.html' %}
{% block header %}Last Tummy Time{% endblock %}
{% block title %}
<strong>{{ tummytime.end|timesince }}</strong> ago
{% endblock %}
{% block content %}
<div class="text-muted">
{{ tummytime.duration }}
{% if tummytime.milestone %}
<br /> {{ tummytime.milestone }}
{% endif %}
</div>
{% endblock %}
{% block footer %}{{ tummytime.end }}{% endblock %}

View File

@ -5,28 +5,10 @@
{% block content %} {% block content %}
<h1 class="text-center">{{ object }}</h1> <h1 class="text-center">{{ object }}</h1>
<div class="container"> <div class="card-columns">
<div class="row align-items-start text-center"> {% card_feeding_last object %}
<div class="col-sm-12 col-md-4"> {% card_diaperchange_last object %}
{% card_feeding_last object %} {% card_tummytime_last object %}
</div> {% card_sleep_last object %}
<div class="col-sm-12 col-md-4">
{% card_diaperchange_last object %}
</div>
<div class="col-sm-12 col-md-4">
change statistics
</div>
</div>
<div class="row align-items-start text-center">
<div class="col-sm-12 col-md-4">
tummy time for the day
</div>
<div class="col-sm-12 col-md-4">
available
</div>
<div class="col-sm-12 col-md-4">
available
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django import template from django import template
from core.models import DiaperChange, Feeding from core.models import DiaperChange, Feeding, Sleep, TummyTime
register = template.Library() register = template.Library()
@ -11,13 +11,24 @@ register = template.Library()
@register.inclusion_tag('cards/feeding_last.html') @register.inclusion_tag('cards/feeding_last.html')
def card_feeding_last(child): def card_feeding_last(child):
feeding_instance = Feeding.objects.filter( instance = Feeding.objects.filter(child=child).order_by('-end').first()
child=child).order_by('-end').first() return {'feeding': instance}
return {'feeding': feeding_instance}
@register.inclusion_tag('cards/diaperchange_last.html') @register.inclusion_tag('cards/diaperchange_last.html')
def card_diaperchange_last(child): def card_diaperchange_last(child):
feeding_instance = DiaperChange.objects.filter( instance = DiaperChange.objects.filter(
child=child).order_by('-time').first() child=child).order_by('-time').first()
return {'change': feeding_instance} return {'change': instance}
@register.inclusion_tag('cards/tummytime_last.html')
def card_tummytime_last(child):
instance = TummyTime.objects.filter(child=child).order_by('-end').first()
return {'tummytime': instance}
@register.inclusion_tag('cards/sleep_last.html')
def card_sleep_last(child):
instance = Sleep.objects.filter(child=child).order_by('-end').first()
return {'sleep': instance}