Add tags to timeline and all list views

This commit is contained in:
Paul Konstantin Gerke 2022-03-08 15:28:32 +01:00 committed by Christopher Charbonneau Wells
parent 4919222d41
commit 5446c5a02c
12 changed files with 66 additions and 18 deletions

View File

@ -123,11 +123,10 @@ class Tag(TagBase):
@property
def complementary_color(self):
DARK, LIGHT = '#101010', '#EFEFEF'
DARK, LIGHT = "#101010", "#EFEFEF"
if not self.color:
return DARK
r, g, b = [int(x, 16) for x in re.match("#(..)(..)(..)", self.color).groups()]
yiq = ((r * 299) + (g * 587) + (b * 114)) // 1000
if yiq >= 128:

View File

@ -27,6 +27,7 @@
<th>{% trans "Child" %}</th>
{% endif %}
<th>{% trans "BMI" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -55,15 +56,18 @@
<td><a href="{% url 'core:child' bmi.child.slug %}">{{ bmi.child }}</a></td>
{% endif %}
<td>{{ bmi.bmi }}</td>
<td>
{% include "core/render_tag_list.html" with tags=bmi.tags.all %}
</td>
</tr>
{% if bmi.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="4"><i class="icon-note mr-2" aria-hidden="true"></i>{{ bmi.notes }}</td>
<td colspan="5"><i class="icon-note mr-2" aria-hidden="true"></i>{{ bmi.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="4">{% trans "No bmi entries found." %}</th>
<th colspan="5">{% trans "No bmi entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -29,6 +29,7 @@
<th class="text-center">{% trans "Contents" %}</th>
<th>{% trans "Color" %}</th>
<th>{% trans "Amount" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -62,6 +63,9 @@
</td>
<td>{{ change.get_color_display }}</td>
<td>{{ change.amount|default_if_none:"" }}</td>
<td>
{% include "core/render_tag_list.html" with tags=change.tags.all %}
</td>
</tr>
{% if change.notes %}
<tr class="{{ row_class }} row-details">
@ -70,7 +74,7 @@
{% endif %}
{% empty %}
<tr>
<th colspan="6">{% trans "No diaper changes found." %}</th>
<th colspan="7">{% trans "No diaper changes found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -31,6 +31,7 @@
{% comment %}Abbreviation of "Amount"{% endcomment %}
<th>{% trans "Amt." %}</th>
<th>{% trans "Duration" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -66,15 +67,18 @@
{% endif %}
</td>
<td>{{ feeding.duration|duration_string }}</td>
<td>
{% include "core/render_tag_list.html" with tags=feeding.tags.all %}
</td>
</tr>
{% if feeding.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="7"><i class="icon-note mr-2" aria-hidden="true"></i>{{ feeding.notes }}</td>
<td colspan="8"><i class="icon-note mr-2" aria-hidden="true"></i>{{ feeding.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="7">{% trans "No feedings found." %}</th>
<th colspan="8">{% trans "No feedings found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -27,6 +27,7 @@
<th>{% trans "Child" %}</th>
{% endif %}
<th>{% trans "Head Circumference" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -55,15 +56,18 @@
<td><a href="{% url 'core:child' head_circumference.child.slug %}">{{ head_circumference.child }}</a></td>
{% endif %}
<td>{{ head_circumference.head_circumference }}</td>
<td>
{% include "core/render_tag_list.html" with tags=head_circumference.tags.all %}
</td>
</tr>
{% if head_circumference.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="4"><i class="icon-note mr-2" aria-hidden="true"></i>{{ head_circumference.notes }}</td>
<td colspan="5"><i class="icon-note mr-2" aria-hidden="true"></i>{{ head_circumference.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="4">{% trans "No head circumference entries found." %}</th>
<th colspan="5">{% trans "No head circumference entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -27,6 +27,7 @@
<th>{% trans "Child" %}</th>
{% endif %}
<th>{% trans "Height" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -55,15 +56,18 @@
<td><a href="{% url 'core:child' height.child.slug %}">{{ height.child }}</a></td>
{% endif %}
<td>{{ height.height }}</td>
<td>
{% include "core/render_tag_list.html" with tags=height.tags.all %}
</td>
</tr>
{% if height.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="4"><i class="icon-note mr-2" aria-hidden="true"></i>{{ height.notes }}</td>
<td colspan="5"><i class="icon-note mr-2" aria-hidden="true"></i>{{ height.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="4">{% trans "No height entries found." %}</th>
<th colspan="5">{% trans "No height entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -29,6 +29,7 @@
{% endif %}
<th>{% trans "Duration" %}</th>
<th class="text-center">{% trans "Nap" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -59,15 +60,18 @@
{% endif %}
<td>{{ sleep.duration|duration_string }}</td>
<td class="text-center">{{ sleep.nap|bool_icon }}</td>
<td>
{% include "core/render_tag_list.html" with tags=sleep.tags.all %}
</td>
</tr>
{% if sleep.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="6"><i class="icon-note mr-2" aria-hidden="true"></i>{{ sleep.notes }}</td>
<td colspan="7"><i class="icon-note mr-2" aria-hidden="true"></i>{{ sleep.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="6">{% trans "No sleep entries found." %}</th>
<th colspan="7">{% trans "No sleep entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -27,6 +27,7 @@
<th>{% trans "Child" %}</th>
{% endif %}
<th>{% trans "Temperature" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -55,15 +56,18 @@
<td><a href="{% url 'core:child' temperature.child.slug %}">{{ temperature.child }}</a></td>
{% endif %}
<td>{{ temperature.temperature }}</td>
<td>
{% include "core/render_tag_list.html" with tags=temperature.tags.all %}
</td>
</tr>
{% if temperature.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="4"><i class="icon-note mr-2" aria-hidden="true"></i>{{ temperature.notes }}</td>
<td colspan="5"><i class="icon-note mr-2" aria-hidden="true"></i>{{ temperature.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="4">{% trans "No temperature entries found." %}</th>
<th colspan="5">{% trans "No temperature entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -28,6 +28,7 @@
{% endif %}
<th>{% trans "Duration" %}</th>
<th>{% trans "Milestone" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -57,10 +58,13 @@
{% endif %}
<td>{{ tummytime.duration|duration_string }}</td>
<td>{{ tummytime.milestone }}</td>
<td>
{% include "core/render_tag_list.html" with tags=tummytime.tags.all %}
</td>
</tr>
{% empty %}
<tr>
<th colspan="6">{% trans "No tummy time entries found." %}</th>
<th colspan="7">{% trans "No tummy time entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -27,6 +27,7 @@
<th>{% trans "Child" %}</th>
{% endif %}
<th>{% trans "Weight" %}</th>
<th>{% trans "Tags" %}</th>
</tr>
</thead>
<tbody>
@ -55,15 +56,18 @@
<td><a href="{% url 'core:child' weight.child.slug %}">{{ weight.child }}</a></td>
{% endif %}
<td>{{ weight.weight }}</td>
<td>
{% include "core/render_tag_list.html" with tags=weight.tags.all %}
</td>
</tr>
{% if weight.notes %}
<tr class="{{ row_class }} row-details">
<td colspan="4"><i class="icon-note mr-2" aria-hidden="true"></i>{{ weight.notes }}</td>
<td colspan="5"><i class="icon-note mr-2" aria-hidden="true"></i>{{ weight.notes }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<th colspan="4">{% trans "No weight entries found." %}</th>
<th colspan="5">{% trans "No weight entries found." %}</th>
</tr>
{% endfor %}
</tbody>

View File

@ -28,6 +28,11 @@
{% for detail in object.details %}
<div><small>{{ detail }}</small></div>
{% endfor %}
{% if object.tags %}
<div>
{% include "core/render_tag_list.html" with tags=object.tags %}
</div>
{% endif %}
</div>
<div class="card-footer text-muted">
{% blocktrans trimmed with since=object.time|timesince time=object.time|time %}

View File

@ -56,6 +56,7 @@ def _add_tummy_times(min_date, max_date, events, child=None):
"edit_link": edit_link,
"model_name": instance.model_name,
"type": "start",
"tags": instance.tags.all(),
}
)
events.append(
@ -68,6 +69,7 @@ def _add_tummy_times(min_date, max_date, events, child=None):
"duration": timesince.timesince(instance.start, now=instance.end),
"model_name": instance.model_name,
"type": "end",
"tags": instance.tags.all(),
}
)
@ -92,6 +94,7 @@ def _add_sleeps(min_date, max_date, events, child=None):
"edit_link": edit_link,
"model_name": instance.model_name,
"type": "start",
"tags": instance.tags.all(),
}
)
events.append(
@ -103,6 +106,7 @@ def _add_sleeps(min_date, max_date, events, child=None):
"duration": timesince.timesince(instance.start, now=instance.end),
"model_name": instance.model_name,
"type": "end",
"tags": instance.tags.all(),
}
)
@ -145,6 +149,7 @@ def _add_feedings(min_date, max_date, events, child=None):
"time_since_prev": time_since_prev,
"model_name": instance.model_name,
"type": "start",
"tags": instance.tags.all(),
}
)
events.append(
@ -157,6 +162,7 @@ def _add_feedings(min_date, max_date, events, child=None):
"duration": timesince.timesince(instance.start, now=instance.end),
"model_name": instance.model_name,
"type": "end",
"tags": instance.tags.all(),
}
)
@ -183,6 +189,7 @@ def _add_diaper_changes(min_date, max_date, events, child):
},
"edit_link": reverse("core:diaperchange-update", args=[instance.id]),
"model_name": instance.model_name,
"tags": instance.tags.all(),
}
)
@ -198,5 +205,6 @@ def _add_notes(min_date, max_date, events, child):
"details": [instance.note],
"edit_link": reverse("core:note-update", args=[instance.id]),
"model_name": instance.model_name,
"tags": instance.tags.all(),
}
)