Add example "Last Feeding" dashboard card.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-18 08:49:15 -04:00
parent b6ba6d440f
commit fe2b704d16
3 changed files with 31 additions and 7 deletions

View File

@ -1,4 +1,5 @@
{% extends 'babyblotter/page.html' %} {% extends 'babyblotter/page.html' %}
{% load dashboard_cards %}
{% block title %}Dashboard - {{ object }}{% endblock %} {% block title %}Dashboard - {{ object }}{% endblock %}
@ -6,24 +7,24 @@
<h1 class="text-center">{{ object }}</h1> <h1 class="text-center">{{ object }}</h1>
<div class="container"> <div class="container">
<div class="row align-items-start text-center"> <div class="row align-items-start text-center">
<div class="col-sm-12 col-md-4 border"> <div class="col-sm-12 col-md-4">
awake time {% feeding_last object %}
</div> </div>
<div class="col-sm-12 col-md-4 border"> <div class="col-sm-12 col-md-4">
last feeding last feeding
</div> </div>
<div class="col-sm-12 col-md-4 border"> <div class="col-sm-12 col-md-4">
change statistics change statistics
</div> </div>
</div> </div>
<div class="row align-items-start text-center"> <div class="row align-items-start text-center">
<div class="col-sm-12 col-md-4 border"> <div class="col-sm-12 col-md-4">
tummy time for the day tummy time for the day
</div> </div>
<div class="col-sm-12 col-md-4 border"> <div class="col-sm-12 col-md-4">
available available
</div> </div>
<div class="col-sm-12 col-md-4 border"> <div class="col-sm-12 col-md-4">
available available
</div> </div>
</div> </div>

View File

@ -0,0 +1,8 @@
<div class="card border-primary mb-3">
<div class="card-header text-white bg-primary">
<i class="fa fa-2x fa-spoon" aria-hidden="true"></i></div>
<div class="card-body text-primary">
<h4 class="card-title">Last Feeding</h4>
<p class="card-text text-muted small">{{ feeding }}</p>
</div>
</div>

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django import template
from core.models import Feeding
register = template.Library()
@register.inclusion_tag('dashboard_cards/feeding_last.html')
def feeding_last(child):
feeding_instance = Feeding.objects.filter(child=child).last()
return {'feeding': feeding_instance}