Re-order list displays and add a boolean formatter template tag.

This commit is contained in:
Christopher Charbonneau Wells 2017-09-10 16:24:59 -04:00
parent 6d1f35cd59
commit 44dd4877a6
7 changed files with 46 additions and 24 deletions

View File

@ -1,5 +1,6 @@
{% extends 'babyblotter/page.html' %}
{% load widget_tweaks %}
{% load bootstrap %}
{% block title %}Diaper Changes{% endblock %}
@ -10,10 +11,10 @@
<thead class="thead-inverse">
<tr>
<th>Child</th>
<th>Time</th>
<th>Wet</th>
<th>Solid</th>
<th>Color</th>
<th>Time</th>
<th class="text-center">Actions</th>
</tr>
</thead>
@ -21,10 +22,10 @@
{% for change in object_list %}
<tr>
<th scope="row">{{ change.child }}</th>
<td>{{ change.time }}</td>
<td>{{ change.wet }}</td>
<td>{{ change.solid }}</td>
<td class="text-center">{{ change.wet|bool_icon }}</td>
<td class="text-center">{{ change.solid|bool_icon }}</td>
<td>{{ change.color }}</td>
<td>{{ change.time|date:'n/j/y G:i' }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">

View File

@ -11,11 +11,11 @@
<thead class="thead-inverse">
<tr>
<th>Child</th>
<th>Date</th>
<th>Duration</th>
<th>Type</th>
<th>Method</th>
<th>Amount (oz)</th>
<th>Type</th>
<th>Amt.</th>
<th>Duration</th>
<th>Date</th>
<th class="text-center">Actions</th>
</tr>
</thead>
@ -23,11 +23,15 @@
{% for feeding in object_list %}
<tr>
<th scope="row">{{ feeding.child }}</th>
<td>{{ feeding.start }}</td>
<td>{{ feeding.duration|duration_string }}</td>
<td>{{ feeding.type }}</td>
<td>{{ feeding.method }}</td>
<td>{{ feeding.amount }}</td>
<td>{{ feeding.type }}</td>
<td>
{% if feeding.amount %}
{{ feeding.amount }} oz.
{% endif %}
</td>
<td>{{ feeding.duration|duration_string }}</td>
<td>{{ feeding.start|date:'n/j/y G:i' }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">

View File

@ -11,9 +11,9 @@
<thead class="thead-inverse">
<tr>
<th>Child</th>
<th>Duration</th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
<th class="text-center">Actions</th>
</tr>
</thead>
@ -21,9 +21,9 @@
{% for sleep in object_list %}
<tr>
<th scope="row">{{ sleep.child }}</th>
<td>{{ sleep.start }}</td>
<td>{{ sleep.end }}</td>
<td>{{ sleep.duration|duration_string }}</td>
<td>{{ sleep.start|date:'n/j/y G:i' }}</td>
<td>{{ sleep.end|date:'n/j/y G:i' }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">

View File

@ -1,6 +1,7 @@
{% extends 'babyblotter/page.html' %}
{% load widget_tweaks %}
{% load bootstrap %}
{% load duration %}
{% load widget_tweaks %}
{% block title %}Sleep{% endblock %}
@ -12,8 +13,8 @@
<tr>
<th>Name</th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
<th>End</th>
<th>Active</th>
<th>User</th>
</tr>
@ -22,10 +23,10 @@
{% for timer in object_list %}
<tr>
<th scope="row"><a href="{% url 'timer-detail' timer.id %}">{{ timer }}</a></th>
<td>{{ timer.start }}</td>
<td>{{ timer.end }}</td>
<td>{{ timer.start|date:'n/j/y G:i' }}</td>
<td>{{ timer.duration|duration_string }}</td>
<td>{{ timer.active }}</td>
<td>{{ timer.end|date:'n/j/y G:i' }}</td>
<td>{{ timer.active|bool_icon }}</td>
<td>{{ timer.user }}</td>
</tr>
{% empty %}

View File

@ -11,9 +11,9 @@
<thead class="thead-inverse">
<tr>
<th>Child</th>
<th>Duration</th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
<th>Milestone</th>
<th class="text-center">Actions</th>
</tr>
@ -22,9 +22,9 @@
{% for tummytime in object_list %}
<tr>
<th scope="row">{{ tummytime.child }}</th>
<td>{{ tummytime.start }}</td>
<td>{{ tummytime.end }}</td>
<td>{{ tummytime.duration|duration_string }}</td>
<td>{{ tummytime.start|date:'n/j/y G:i' }}</td>
<td>{{ tummytime.end|date:'n/j/y G:i' }}</td>
<td>{{ tummytime.milestone }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter()
def bool_icon(value):
if value:
classes = 'fa-check-circle-o text-success'
else:
classes = 'fa-times-circle-o text-danger'
icon_html = '<i class="fa {}" aria-hidden="true"></i>'.format(classes)
return mark_safe(icon_html)

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.core.urlresolvers import resolve
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.urls import reverse
from django.views.generic.base import RedirectView