mirror of https://github.com/snachodog/mybuddy.git
parent
e7862801b1
commit
20d9cab158
|
@ -9,32 +9,11 @@
|
||||||
<a href="{% url 'core:child' object.slug %}" class="btn" title="{% trans "Timeline" %}">
|
<a href="{% url 'core:child' object.slug %}" class="btn" title="{% trans "Timeline" %}">
|
||||||
<i class="icon-timeline" aria-hidden="true"></i>
|
<i class="icon-timeline" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{% url 'reports:report-list' object.slug %}" class="btn" title="{% trans "Reports" %}">
|
||||||
|
<i class="icon-graph" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
<button id="reports-dropdown"
|
|
||||||
class="btn dropdown-toggle"
|
|
||||||
title="{% trans "Reports" %}"
|
|
||||||
type="button"
|
|
||||||
data-toggle="dropdown"
|
|
||||||
aria-haspopup="true"
|
|
||||||
aria-expanded="false"><i class="icon-graph" aria-hidden="true"></i></button>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="reports-dropdown">
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-amounts-child' object.slug %}">{% trans "Diaper Change Amounts" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-types-child' object.slug %}">{% trans "Diaper Change Types" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-lifetimes-child' object.slug %}">{% trans "Diaper Lifetimes" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-feeding-amounts-child' object.slug %}">{% trans "Feeding Amounts" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-feeding-duration-child' object.slug %}">{% trans "Feeding Durations (Average)" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-sleep-pattern-child' object.slug %}">{% trans "Sleep Pattern" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-sleep-totals-child' object.slug %}">{% trans "Sleep Totals" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-tummytime-duration-child' object.slug %}">{% trans "Tummy Time Durations (Sum)" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-weight-weight-child' object.slug %}">{% trans "Weight" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-height-height-child' object.slug %}">{% trans "Height" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-head-circumference-head-circumference-child' object.slug %}">{% trans "Head Circumference" %}</a>
|
|
||||||
<a class="dropdown-item" href="{% url 'reports:report-bmi-bmi-child' object.slug %}">{% trans "BMI" %}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if perms.core.change_child %}
|
{% if perms.core.change_child %}
|
||||||
<a class="btn d-none d-md-inline-block"
|
<a class="btn d-none d-md-inline-block"
|
||||||
href="{% url 'core:child-update' object.slug %}"
|
href="{% url 'core:child-update' object.slug %}"
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends 'babybuddy/page.html' %}
|
||||||
|
{% load i18n static %}
|
||||||
|
|
||||||
|
{% block title %}{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">{% trans "Children" %}</a></li>
|
||||||
|
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:child' object.slug %}">{{ object }}</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{% url 'reports:report-list' object.slug %}">{% trans "Reports" %}</a></li>
|
||||||
|
{% endblock %}
|
|
@ -1,12 +1,10 @@
|
||||||
{% extends 'babybuddy/page.html' %}
|
{% extends 'reports/base.html' %}
|
||||||
{% load i18n static %}
|
{% load i18n static %}
|
||||||
|
|
||||||
{% block title %}{% endblock %}
|
{% block title %}{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">{% trans "Children" %}</a></li>
|
{{ block.super }}
|
||||||
<li class="breadcrumb-item font-weight-bold"><a href="{% url 'core:child' object.slug %}">{{ object }}</a></li>
|
|
||||||
<li class="breadcrumb-item">{% trans "Reports" %}</li>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
{% extends 'reports/base.html' %}
|
||||||
|
{% load i18n static %}
|
||||||
|
|
||||||
|
{% block title %}{% trans "Reports" %} - {{ object }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container-fluid">
|
||||||
|
<h1>Reports</h1>
|
||||||
|
<div class="list-group">
|
||||||
|
<a href="{% url 'reports:report-bmi-bmi-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Body Mass Index (BMI)" %}</a>
|
||||||
|
<a href="{% url 'reports:report-diaperchange-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Change Amounts" %}</a>
|
||||||
|
<a href="{% url 'reports:report-diaperchange-types-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Change Types" %}</a>
|
||||||
|
<a href="{% url 'reports:report-diaperchange-lifetimes-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Lifetimes" %}</a>
|
||||||
|
<a href="{% url 'reports:report-feeding-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Amounts" %}</a>
|
||||||
|
<a href="{% url 'reports:report-feeding-duration-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Durations (Average)" %}</a>
|
||||||
|
<a href="{% url 'reports:report-head-circumference-head-circumference-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Head Circumference" %}</a>
|
||||||
|
<a href="{% url 'reports:report-height-height-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Height" %}</a>
|
||||||
|
<a href="{% url 'reports:report-sleep-pattern-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Sleep Pattern" %}</a>
|
||||||
|
<a href="{% url 'reports:report-sleep-totals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Sleep Totals" %}</a>
|
||||||
|
<a href="{% url 'reports:report-tummytime-duration-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Tummy Time Durations (Sum)" %}</a>
|
||||||
|
<a href="{% url 'reports:report-weight-weight-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Weight" %}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -32,6 +32,9 @@ class ViewsTestCase(TestCase):
|
||||||
child = models.Child.objects.first()
|
child = models.Child.objects.first()
|
||||||
base_url = "/children/{}/reports".format(child.slug)
|
base_url = "/children/{}/reports".format(child.slug)
|
||||||
|
|
||||||
|
page = self.c.get(base_url)
|
||||||
|
self.assertEqual(page.status_code, 200)
|
||||||
|
|
||||||
page = self.c.get("{}/changes/amounts/".format(base_url))
|
page = self.c.get("{}/changes/amounts/".format(base_url))
|
||||||
self.assertEqual(page.status_code, 200)
|
self.assertEqual(page.status_code, 200)
|
||||||
page = self.c.get("{}/changes/lifetimes/".format(base_url))
|
page = self.c.get("{}/changes/lifetimes/".format(base_url))
|
||||||
|
|
|
@ -6,6 +6,11 @@ from . import views
|
||||||
app_name = "reports"
|
app_name = "reports"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path(
|
||||||
|
"children/<str:slug>/reports",
|
||||||
|
views.ChildReportList.as_view(),
|
||||||
|
name="report-list",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"children/<str:slug>/reports/changes/amounts/",
|
"children/<str:slug>/reports/changes/amounts/",
|
||||||
views.DiaperChangeAmounts.as_view(),
|
views.DiaperChangeAmounts.as_view(),
|
||||||
|
|
|
@ -7,6 +7,16 @@ from core import models
|
||||||
from . import graphs
|
from . import graphs
|
||||||
|
|
||||||
|
|
||||||
|
class ChildReportList(PermissionRequiredMixin, DetailView):
|
||||||
|
"""
|
||||||
|
Listing of available reports for a child.
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = models.Child
|
||||||
|
permission_required = ("core.view_child",)
|
||||||
|
template_name = "reports/report_list.html"
|
||||||
|
|
||||||
|
|
||||||
class DiaperChangeAmounts(PermissionRequiredMixin, DetailView):
|
class DiaperChangeAmounts(PermissionRequiredMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Graph of diaper "amounts" - measurements of urine output.
|
Graph of diaper "amounts" - measurements of urine output.
|
||||||
|
@ -109,29 +119,6 @@ class FeedingDurationChildReport(PermissionRequiredMixin, DetailView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class TummyTimeDurationChildReport(PermissionRequiredMixin, DetailView):
|
|
||||||
"""
|
|
||||||
Graph of tummy time durations over time.
|
|
||||||
"""
|
|
||||||
|
|
||||||
model = models.Child
|
|
||||||
permission_required = ("core.view_child",)
|
|
||||||
template_name = "reports/tummytime_duration.html"
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(TummyTimeDurationChildReport, self).__init__()
|
|
||||||
self.html = ""
|
|
||||||
self.js = ""
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(TummyTimeDurationChildReport, self).get_context_data(**kwargs)
|
|
||||||
child = context["object"]
|
|
||||||
instances = models.TummyTime.objects.filter(child=child)
|
|
||||||
if instances:
|
|
||||||
context["html"], context["js"] = graphs.tummytime_duration(instances)
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class SleepPatternChildReport(PermissionRequiredMixin, DetailView):
|
class SleepPatternChildReport(PermissionRequiredMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Graph of sleep pattern comparing sleep to wake times by day.
|
Graph of sleep pattern comparing sleep to wake times by day.
|
||||||
|
@ -178,6 +165,29 @@ class SleepTotalsChildReport(PermissionRequiredMixin, DetailView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class TummyTimeDurationChildReport(PermissionRequiredMixin, DetailView):
|
||||||
|
"""
|
||||||
|
Graph of tummy time durations over time.
|
||||||
|
"""
|
||||||
|
|
||||||
|
model = models.Child
|
||||||
|
permission_required = ("core.view_child",)
|
||||||
|
template_name = "reports/tummytime_duration.html"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(TummyTimeDurationChildReport, self).__init__()
|
||||||
|
self.html = ""
|
||||||
|
self.js = ""
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(TummyTimeDurationChildReport, self).get_context_data(**kwargs)
|
||||||
|
child = context["object"]
|
||||||
|
instances = models.TummyTime.objects.filter(child=child)
|
||||||
|
if instances:
|
||||||
|
context["html"], context["js"] = graphs.tummytime_duration(instances)
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
class WeightWeightChildReport(PermissionRequiredMixin, DetailView):
|
class WeightWeightChildReport(PermissionRequiredMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Graph of weight change over time.
|
Graph of weight change over time.
|
||||||
|
|
Loading…
Reference in New Issue