diff --git a/dashboard/templates/dashboard/child_button_group.html b/dashboard/templates/dashboard/child_button_group.html index 363c2be2..5f9fc52a 100644 --- a/dashboard/templates/dashboard/child_button_group.html +++ b/dashboard/templates/dashboard/child_button_group.html @@ -9,32 +9,11 @@ + + + {% endif %} -
- - -
- {% if perms.core.change_child %} {% trans "Children" %} + + +{% endblock %} diff --git a/reports/templates/reports/report_base.html b/reports/templates/reports/report_base.html index d3c47b61..035acf2c 100644 --- a/reports/templates/reports/report_base.html +++ b/reports/templates/reports/report_base.html @@ -1,12 +1,10 @@ -{% extends 'babybuddy/page.html' %} +{% extends 'reports/base.html' %} {% load i18n static %} {% block title %}{% endblock %} {% block breadcrumbs %} - - - + {{ block.super }} {% endblock %} {% block content %} diff --git a/reports/templates/reports/report_list.html b/reports/templates/reports/report_list.html new file mode 100644 index 00000000..66512eac --- /dev/null +++ b/reports/templates/reports/report_list.html @@ -0,0 +1,24 @@ +{% extends 'reports/base.html' %} +{% load i18n static %} + +{% block title %}{% trans "Reports" %} - {{ object }}{% endblock %} + +{% block content %} +
+

Reports

+
+ {% trans "Body Mass Index (BMI)" %} + {% trans "Diaper Change Amounts" %} + {% trans "Diaper Change Types" %} + {% trans "Diaper Lifetimes" %} + {% trans "Feeding Amounts" %} + {% trans "Feeding Durations (Average)" %} + {% trans "Head Circumference" %} + {% trans "Height" %} + {% trans "Sleep Pattern" %} + {% trans "Sleep Totals" %} + {% trans "Tummy Time Durations (Sum)" %} + {% trans "Weight" %} +
+
+{% endblock %} \ No newline at end of file diff --git a/reports/tests/tests_views.py b/reports/tests/tests_views.py index c823dcb4..1aed4a53 100644 --- a/reports/tests/tests_views.py +++ b/reports/tests/tests_views.py @@ -32,6 +32,9 @@ class ViewsTestCase(TestCase): child = models.Child.objects.first() 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)) self.assertEqual(page.status_code, 200) page = self.c.get("{}/changes/lifetimes/".format(base_url)) diff --git a/reports/urls.py b/reports/urls.py index 09245184..213b479a 100644 --- a/reports/urls.py +++ b/reports/urls.py @@ -6,6 +6,11 @@ from . import views app_name = "reports" urlpatterns = [ + path( + "children//reports", + views.ChildReportList.as_view(), + name="report-list", + ), path( "children//reports/changes/amounts/", views.DiaperChangeAmounts.as_view(), diff --git a/reports/views.py b/reports/views.py index bcd69f96..7c0bdb48 100644 --- a/reports/views.py +++ b/reports/views.py @@ -7,6 +7,16 @@ from core import models 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): """ Graph of diaper "amounts" - measurements of urine output. @@ -109,29 +119,6 @@ class FeedingDurationChildReport(PermissionRequiredMixin, DetailView): 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): """ Graph of sleep pattern comparing sleep to wake times by day. @@ -178,6 +165,29 @@ class SleepTotalsChildReport(PermissionRequiredMixin, DetailView): 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): """ Graph of weight change over time.