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 @property
def complementary_color(self): def complementary_color(self):
DARK, LIGHT = '#101010', '#EFEFEF' DARK, LIGHT = "#101010", "#EFEFEF"
if not self.color: if not self.color:
return DARK return DARK
r, g, b = [int(x, 16) for x in re.match("#(..)(..)(..)", self.color).groups()] r, g, b = [int(x, 16) for x in re.match("#(..)(..)(..)", self.color).groups()]
yiq = ((r * 299) + (g * 587) + (b * 114)) // 1000 yiq = ((r * 299) + (g * 587) + (b * 114)) // 1000
if yiq >= 128: if yiq >= 128:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,6 +28,11 @@
{% for detail in object.details %} {% for detail in object.details %}
<div><small>{{ detail }}</small></div> <div><small>{{ detail }}</small></div>
{% endfor %} {% endfor %}
{% if object.tags %}
<div>
{% include "core/render_tag_list.html" with tags=object.tags %}
</div>
{% endif %}
</div> </div>
<div class="card-footer text-muted"> <div class="card-footer text-muted">
{% blocktrans trimmed with since=object.time|timesince time=object.time|time %} {% 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, "edit_link": edit_link,
"model_name": instance.model_name, "model_name": instance.model_name,
"type": "start", "type": "start",
"tags": instance.tags.all(),
} }
) )
events.append( 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), "duration": timesince.timesince(instance.start, now=instance.end),
"model_name": instance.model_name, "model_name": instance.model_name,
"type": "end", "type": "end",
"tags": instance.tags.all(),
} }
) )
@ -92,6 +94,7 @@ def _add_sleeps(min_date, max_date, events, child=None):
"edit_link": edit_link, "edit_link": edit_link,
"model_name": instance.model_name, "model_name": instance.model_name,
"type": "start", "type": "start",
"tags": instance.tags.all(),
} }
) )
events.append( events.append(
@ -103,6 +106,7 @@ def _add_sleeps(min_date, max_date, events, child=None):
"duration": timesince.timesince(instance.start, now=instance.end), "duration": timesince.timesince(instance.start, now=instance.end),
"model_name": instance.model_name, "model_name": instance.model_name,
"type": "end", "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, "time_since_prev": time_since_prev,
"model_name": instance.model_name, "model_name": instance.model_name,
"type": "start", "type": "start",
"tags": instance.tags.all(),
} }
) )
events.append( events.append(
@ -157,6 +162,7 @@ def _add_feedings(min_date, max_date, events, child=None):
"duration": timesince.timesince(instance.start, now=instance.end), "duration": timesince.timesince(instance.start, now=instance.end),
"model_name": instance.model_name, "model_name": instance.model_name,
"type": "end", "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]), "edit_link": reverse("core:diaperchange-update", args=[instance.id]),
"model_name": instance.model_name, "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], "details": [instance.note],
"edit_link": reverse("core:note-update", args=[instance.id]), "edit_link": reverse("core:note-update", args=[instance.id]),
"model_name": instance.model_name, "model_name": instance.model_name,
"tags": instance.tags.all(),
} }
) )