Create extended template example for Last Feeding.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-18 10:32:17 -04:00
parent 0ed0ae1a94
commit 4cfc6cb360
3 changed files with 32 additions and 8 deletions

View File

@ -0,0 +1,13 @@
<div class="card border-primary mb-3">
<div class="card-header text-white bg-primary h4">
<i class="fa fa-spoon pull-left" aria-hidden="true"></i>
{% block header %}{% endblock %}
</div>
<div class="card-body text-primary">
<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

@ -1,8 +1,18 @@
<div class="card border-primary mb-3"> {% extends 'cards/feeding.html' %}
<div class="card-header text-white bg-primary">
<i class="fa fa-2x fa-spoon" aria-hidden="true"></i></div> {% block header %}Last Feeding{% endblock %}
<div class="card-body text-primary">
<h4 class="card-title">Last Feeding</h4> {% block title %}
<p class="card-text text-muted small">{{ feeding }}</p> <strong>{{ feeding.end|timesince }}</strong> ago
{% endblock %}
{% block content %}
<div class="text-muted">
{{ feeding.type }}, {{ feeding.method }}
{% if feeding.amount %}
, {{ feeding.amount }}oz.
{% endif %}
</div> </div>
</div> {% endblock %}
{% block footer %}{{ feeding.end }}{% endblock %}

View File

@ -11,5 +11,6 @@ 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(child=child).last() feeding_instance = Feeding.objects.filter(
child=child).order_by('-end').first()
return {'feeding': feeding_instance} return {'feeding': feeding_instance}