From fe2b704d1694e41a14e3121719e34e7950b52559 Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Fri, 18 Aug 2017 08:49:15 -0400 Subject: [PATCH] Add example "Last Feeding" dashboard card. --- core/templates/core/child_dashboard.html | 15 ++++++++------- core/templates/dashboard_cards/feeding_last.html | 8 ++++++++ core/templatetags/dashboard_cards.py | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 core/templates/dashboard_cards/feeding_last.html create mode 100644 core/templatetags/dashboard_cards.py diff --git a/core/templates/core/child_dashboard.html b/core/templates/core/child_dashboard.html index a35c358d..faa919e6 100644 --- a/core/templates/core/child_dashboard.html +++ b/core/templates/core/child_dashboard.html @@ -1,4 +1,5 @@ {% extends 'babyblotter/page.html' %} +{% load dashboard_cards %} {% block title %}Dashboard - {{ object }}{% endblock %} @@ -6,24 +7,24 @@

{{ object }}

-
- awake time +
+ {% feeding_last object %}
-
+
last feeding
-
+
change statistics
-
+
tummy time for the day
-
+
available
-
+
available
diff --git a/core/templates/dashboard_cards/feeding_last.html b/core/templates/dashboard_cards/feeding_last.html new file mode 100644 index 00000000..1c0cefb8 --- /dev/null +++ b/core/templates/dashboard_cards/feeding_last.html @@ -0,0 +1,8 @@ +
+
+
+
+

Last Feeding

+

{{ feeding }}

+
+
\ No newline at end of file diff --git a/core/templatetags/dashboard_cards.py b/core/templatetags/dashboard_cards.py new file mode 100644 index 00000000..1ef0bffd --- /dev/null +++ b/core/templatetags/dashboard_cards.py @@ -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}