Add a last pumping dashboard card (#604)

* Add a last pumping dashboard card

* Update static assets

* Add domain during dokku CI pre-deploy
This commit is contained in:
Christopher Charbonneau Wells 2023-02-15 20:22:27 -08:00 committed by GitHub
parent a5504520d1
commit 08ba1a32a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 79 additions and 10 deletions

View File

@ -3,5 +3,6 @@
if [ "$IS_REVIEW_APP" = "true" ]; then if [ "$IS_REVIEW_APP" = "true" ]; then
DOMAIN="$APP_NAME.dokku.baby-buddy.net" DOMAIN="$APP_NAME.dokku.baby-buddy.net"
ssh "$SSH_REMOTE" -- config:set "$APP_NAME" "ALLOWED_HOSTS=$DOMAIN CSRF_TRUSTED_ORIGINS=http://$DOMAIN" ssh "$SSH_REMOTE" -- config:set "$APP_NAME" "ALLOWED_HOSTS=$DOMAIN CSRF_TRUSTED_ORIGINS=http://$DOMAIN"
ssh "$SSH_REMOTE" -- domains:add "$APP_NAME" "$DOMAIN"
echo "Review app configured" echo "Review app configured"
fi fi

View File

@ -48,7 +48,8 @@
} }
} }
.card-feeding { .card-feeding,
.card-pumping {
border-color: theme-color('primary'); border-color: theme-color('primary');
.card-header, .card-header a { .card-header, .card-header a {

View File

@ -0,0 +1,25 @@
{% extends 'cards/base.html' %}
{% load duration i18n %}
{% block header %}
<a href="{% url "core:pumping-list" %}">
{% trans "Last Pumping" %}
</a>
{% endblock %}
{% block title %}
{% if pumping %}
{% blocktrans trimmed with since=pumping.time|deltasince|duration_string:'m' time=pumping.time|time %}
<div>{{ since }} ago</div>
<small>{{ time }}</small>
{% endblocktrans %}
{% else %}
{% trans "None" %}
{% endif %}
{% endblock %}
{% block content %}
{% if pumping %}
{% trans "Amount" %}: {{ pumping.amount }}
{% endif %}
{% endblock %}

View File

@ -15,6 +15,7 @@
<div id="dashboard-child" class="card-columns"> <div id="dashboard-child" class="card-columns">
{% card_timer_list object %} {% card_timer_list object %}
{% card_feeding_last object %} {% card_feeding_last object %}
{% card_pumping_last object %}
{% card_diaperchange_last object %} {% card_diaperchange_last object %}
{% card_sleep_last object %} {% card_sleep_last object %}
{% card_feeding_last_method object %} {% card_feeding_last_method object %}

View File

@ -198,6 +198,29 @@ def card_feeding_last_method(context, child):
} }
@register.inclusion_tag("cards/pumping_last.html", takes_context=True)
def card_pumping_last(context, child):
"""
Information about the most recent pumping.
:param child: an instance of the Child model.
:returns: a dictionary with the most recent Pumping instance.
"""
instance = (
models.Pumping.objects.filter(child=child)
.filter(**_filter_data_age(context))
.order_by("-time")
.first()
)
empty = not instance
return {
"type": "pumping",
"pumping": instance,
"empty": empty,
"hide_empty": _hide_empty(context),
}
@register.inclusion_tag("cards/sleep_last.html", takes_context=True) @register.inclusion_tag("cards/sleep_last.html", takes_context=True)
def card_sleep_last(context, child): def card_sleep_last(context, child):
""" """

View File

@ -188,6 +188,14 @@ class TemplateTagsTestCase(TestCase):
data["feedings"][2].method, models.Feeding.objects.first().method data["feedings"][2].method, models.Feeding.objects.first().method
) )
def test_card_pumping_last(self):
data = cards.card_pumping_last(self.context, self.child)
self.assertEqual(data["type"], "pumping")
self.assertFalse(data["empty"])
self.assertFalse(data["hide_empty"])
self.assertIsInstance(data["pumping"], models.Pumping)
self.assertEqual(data["pumping"], models.Pumping.objects.first())
def test_card_sleep_last(self): def test_card_sleep_last(self):
data = cards.card_sleep_last(self.context, self.child) data = cards.card_sleep_last(self.context, self.child)
self.assertEqual(data["type"], "sleep") self.assertEqual(data["type"], "sleep")

View File

@ -10117,17 +10117,22 @@ body.tempusdominus-bootstrap-datetimepicker-widget-day-click {
height: 2rem; height: 2rem;
} }
.card-feeding { .card-feeding,
.card-pumping {
border-color: #37abe9; border-color: #37abe9;
} }
.card-feeding .card-header, .card-feeding .card-header a { .card-feeding .card-header, .card-feeding .card-header a,
.card-pumping .card-header,
.card-pumping .card-header a {
background-color: #37abe9; background-color: #37abe9;
color: #f8f9fa; color: #f8f9fa;
} }
.card-feeding .card-body { .card-feeding .card-body,
.card-pumping .card-body {
color: #37abe9; color: #37abe9;
} }
.card-feeding .card-body .last-feeding-method { .card-feeding .card-body .last-feeding-method,
.card-pumping .card-body .last-feeding-method {
font-size: 2em; font-size: 2em;
} }

Binary file not shown.

Binary file not shown.

View File

@ -10117,17 +10117,22 @@ body.tempusdominus-bootstrap-datetimepicker-widget-day-click {
height: 2rem; height: 2rem;
} }
.card-feeding { .card-feeding,
.card-pumping {
border-color: #37abe9; border-color: #37abe9;
} }
.card-feeding .card-header, .card-feeding .card-header a { .card-feeding .card-header, .card-feeding .card-header a,
.card-pumping .card-header,
.card-pumping .card-header a {
background-color: #37abe9; background-color: #37abe9;
color: #f8f9fa; color: #f8f9fa;
} }
.card-feeding .card-body { .card-feeding .card-body,
.card-pumping .card-body {
color: #37abe9; color: #37abe9;
} }
.card-feeding .card-body .last-feeding-method { .card-feeding .card-body .last-feeding-method,
.card-pumping .card-body .last-feeding-method {
font-size: 2em; font-size: 2em;
} }

Binary file not shown.

File diff suppressed because one or more lines are too long