Use short datetime string for lists

This commit is contained in:
Christopher C. Wells 2021-07-31 20:03:18 -07:00 committed by Christopher Charbonneau Wells
parent 58acccfddb
commit 94cb7d771a
8 changed files with 22 additions and 18 deletions

View File

@ -18,5 +18,7 @@ else:
'%m/%d/%Y %I:%M %p', # '10/25/2006 2:30 PM' '%m/%d/%Y %I:%M %p', # '10/25/2006 2:30 PM'
] ]
SHORT_MONTH_DAY_FORMAT = 'M j'
# Append all other input formats from the base locale. # Append all other input formats from the base locale.
DATETIME_INPUT_FORMATS = CUSTOM_INPUT_FORMATS + formats.DATETIME_INPUT_FORMATS DATETIME_INPUT_FORMATS = CUSTOM_INPUT_FORMATS + formats.DATETIME_INPUT_FORMATS

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load duration i18n widget_tweaks %} {% load datetime duration i18n widget_tweaks %}
{% block title %}{% trans "Feedings" %}{% endblock %} {% block title %}{% trans "Feedings" %}{% endblock %}
@ -35,7 +35,7 @@
{% for feeding in object_list %} {% for feeding in object_list %}
{% cycle "odd" "even" as row_class silent %} {% cycle "odd" "even" as row_class silent %}
<tr class="{{ row_class }}"> <tr class="{{ row_class }}">
<th scope="row">{{ feeding.start }}</th> <th scope="row">{{ feeding.start|datetime_short }}</th>
<td><a href="{% url 'core:child' feeding.child.slug %}">{{ feeding.child }}</a></td> <td><a href="{% url 'core:child' feeding.child.slug %}">{{ feeding.child }}</a></td>
<td>{{ feeding.get_method_display }}</td> <td>{{ feeding.get_method_display }}</td>
<td>{{ feeding.get_type_display }}</td> <td>{{ feeding.get_type_display }}</td>

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load i18n widget_tweaks %} {% load datetime i18n widget_tweaks %}
{% block title %}{% trans "Notes" %}{% endblock %} {% block title %}{% trans "Notes" %}{% endblock %}
@ -30,7 +30,7 @@
<tbody> <tbody>
{% for note in object_list %} {% for note in object_list %}
<tr> <tr>
<th scope="row">{{ note.time }}</th> <th scope="row">{{ note.time|datetime_short }}</th>
<td><a href="{% url 'core:child' note.child.slug %}">{{ note.child }}</a></td> <td><a href="{% url 'core:child' note.child.slug %}">{{ note.child }}</a></td>
<td>{{ note.note }}</td> <td>{{ note.note }}</td>
<td class="text-center"> <td class="text-center">

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load bootstrap duration i18n widget_tweaks %} {% load bootstrap datetime duration i18n widget_tweaks %}
{% block title %}{% trans "Sleep" %}{% endblock %} {% block title %}{% trans "Sleep" %}{% endblock %}
@ -33,8 +33,8 @@
{% for sleep in object_list %} {% for sleep in object_list %}
{% cycle "odd" "even" as row_class silent %} {% cycle "odd" "even" as row_class silent %}
<tr class="{{ row_class }}"> <tr class="{{ row_class }}">
<th scope="row">{{ sleep.start }}</th> <th scope="row">{{ sleep.start|datetime_short }}</th>
<td>{{ sleep.end }}</td> <td>{{ sleep.end|datetime_short }}</td>
<td><a href="{% url 'core:child' sleep.child.slug %}">{{ sleep.child }}</a></td> <td><a href="{% url 'core:child' sleep.child.slug %}">{{ sleep.child }}</a></td>
<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>

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load i18n widget_tweaks %} {% load datetime i18n widget_tweaks %}
{% block title %}{% trans "Temperature" %}{% endblock %} {% block title %}{% trans "Temperature" %}{% endblock %}
@ -31,7 +31,7 @@
{% for temperature in object_list %} {% for temperature in object_list %}
{% cycle "odd" "even" as row_class silent %} {% cycle "odd" "even" as row_class silent %}
<tr class="{{ row_class }}"> <tr class="{{ row_class }}">
<th scope="row">{{ temperature.time }}</th> <th scope="row">{{ temperature.time|datetime_short }}</th>
<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>
<td>{{ temperature.temperature }}</td> <td>{{ temperature.temperature }}</td>
<td class="text-center"> <td class="text-center">

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load bootstrap duration i18n widget_tweaks %} {% load bootstrap datetime duration i18n widget_tweaks %}
{% block title %}{% trans "Timers" %}{% endblock %} {% block title %}{% trans "Timers" %}{% endblock %}
@ -33,17 +33,19 @@
<tbody> <tbody>
{% for timer in object_list %} {% for timer in object_list %}
<tr> <tr>
<th scope="row">{{ timer.start }}</th> <th scope="row">{{ timer.start|datetime_short }}</th>
<td><a href="{% url 'core:timer-detail' timer.id %}">{{ timer }}</a></td> <td><a href="{% url 'core:timer-detail' timer.id %}">{{ timer }}</a></td>
<td> <td>
{% if timer.child %} {% if timer.child %}
<a href="{% url 'core:child' timer.child.slug %}">{{ timer.child }}</a> <a href="{% url 'core:child' timer.child.slug %}">{{ timer.child }}</a>
{% else %}
&nbsp;
{% endif %} {% endif %}
</td> </td>
<td>{{ timer.duration|duration_string }}</td> <td>{{ timer.duration|duration_string }}</td>
<td>{{ timer.end }}</td> <td>
{% if timer.end %}
{{ timer.end|datetime_short }}
{% endif %}
</td>
<td>{{ timer.active|bool_icon }}</td> <td>{{ timer.active|bool_icon }}</td>
<td>{{ timer.user_username }}</td> <td>{{ timer.user_username }}</td>
</tr> </tr>

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load duration i18n widget_tweaks %} {% load datetime duration i18n widget_tweaks %}
{% block title %}{% trans "Tummy Time" %}{% endblock %} {% block title %}{% trans "Tummy Time" %}{% endblock %}
@ -31,8 +31,8 @@
<tbody> <tbody>
{% for tummytime in object_list %} {% for tummytime in object_list %}
<tr> <tr>
<th scope="row">{{ tummytime.start }}</th> <th scope="row">{{ tummytime.start|datetime_short }}</th>
<td>{{ tummytime.end }}</td> <td>{{ tummytime.end|datetime_short }}</td>
<td><a href="{% url 'core:child' tummytime.child.slug %}">{{ tummytime.child }}</a></td> <td><a href="{% url 'core:child' tummytime.child.slug %}">{{ tummytime.child }}</a></td>
<td>{{ tummytime.duration|duration_string }}</td> <td>{{ tummytime.duration|duration_string }}</td>
<td>{{ tummytime.milestone }}</td> <td>{{ tummytime.milestone }}</td>

View File

@ -36,7 +36,7 @@ def datetime_short(date):
date_string = _('Today') date_string = _('Today')
time_string = formats.date_format(date, format='TIME_FORMAT') time_string = formats.date_format(date, format='TIME_FORMAT')
elif now.year == date.year: elif now.year == date.year:
date_string = formats.date_format(date, format='MONTH_DAY_FORMAT') date_string = formats.date_format(date, format='SHORT_MONTH_DAY_FORMAT')
time_string = formats.date_format(date, format='TIME_FORMAT') time_string = formats.date_format(date, format='TIME_FORMAT')
else: else:
date_string = formats.date_format(date, format='SHORT_DATETIME_FORMAT') date_string = formats.date_format(date, format='SHORT_DATETIME_FORMAT')