Fixed report breadcrumbs being duplicated. Fixed DiaperChangeTypesChildReport pointing to the wrong report view. Fixed child sw

itcher for WHO weight percentiles boy/girl reports.
This commit is contained in:
Nicholas Trecina 2023-12-01 22:55:38 -07:00 committed by Christopher Charbonneau Wells
parent 7747ae9023
commit 1063d39af0
9 changed files with 47 additions and 22 deletions

View File

@ -5,6 +5,4 @@
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">{% trans "Children" %}</a></li> <li class="breadcrumb-item"><a href="{% url 'core:child-list' %}">{% trans "Children" %}</a></li>
<li class="breadcrumb-item fw-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 %} {% endblock %}

View File

@ -1,7 +1,8 @@
{% load breadcrumb i18n %} {% load breadcrumb i18n %}
<li class="breadcrumb-item font-weight-bold"> {% block breadcrumbs %}
{% child_quick_switch object target_url %} <li class="breadcrumb-item font-weight-bold">
</li> {% child_quick_switch object target_url %}
<li class="breadcrumb-item"><a href="{% url 'reports:report-list' object.slug %}">{% trans "Reports" %}</a></li> </li>
<li class="breadcrumb-item"><a href="{% url 'reports:report-list' object.slug %}">{% trans "Reports" %}</a></li>
{% endblock %}

View File

@ -5,5 +5,6 @@
{% block breadcrumbs %} {% block breadcrumbs %}
{{ block.super }} {{ block.super }}
{% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-diaperchange-intervals-child' %}
<li class="breadcrumb-item active" aria-current="page">{% trans "Diaper Change Intervals" %}</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Diaper Change Intervals" %}</li>
{% endblock %} {% endblock %}

View File

@ -5,5 +5,6 @@
{% block breadcrumbs %} {% block breadcrumbs %}
{{ block.super }} {{ block.super }}
{% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-feeding-intervals-child' %}
<li class="breadcrumb-item active" aria-current="page">{% trans "Feeding Intervals" %}</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Feeding Intervals" %}</li>
{% endblock %} {% endblock %}

View File

@ -32,8 +32,8 @@
<a href="{% url 'reports:report-temperature-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Temperature" %}</a> <a href="{% url 'reports:report-temperature-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Temperature" %}</a>
<a href="{% url 'reports:report-tummy-time-duration-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Tummy Time Durations (Sum)" %}</a> <a href="{% url 'reports:report-tummy-time-duration-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Tummy Time Durations (Sum)" %}</a>
<a href="{% url 'reports:report-weight-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Weight" %}</a> <a href="{% url 'reports:report-weight-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Weight" %}</a>
<a href="{% url 'reports:report-weight-change-child-sex' object.slug 'boy' %}" class="list-group-item list-group-item-action">{% trans "WHO Weight Percentiles for Boys in kg" %}</a> <a href="{% url 'reports:report-weight-change-child-boy' object.slug %}" class="list-group-item list-group-item-action">{% trans "WHO Weight Percentiles for Boys in kg" %}</a>
<a href="{% url 'reports:report-weight-change-child-sex' object.slug 'girl' %}" class="list-group-item list-group-item-action">{% trans "WHO Weight Percentiles for Girls in kg" %}</a> <a href="{% url 'reports:report-weight-change-child-girl' object.slug %}" class="list-group-item list-group-item-action">{% trans "WHO Weight Percentiles for Girls in kg" %}</a>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -5,6 +5,7 @@
{% block breadcrumbs %} {% block breadcrumbs %}
{{ block.super }} {{ block.super }}
{% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-weight-change-child' %} {% include 'reports/breadcrumb_common_chunk.html' with target_url=target_url %}
<li class="breadcrumb-item active" aria-current="page">{% trans "Weight" %}</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Weight" %}</li>
{% endblock %} {% endblock %}

View File

@ -92,8 +92,13 @@ urlpatterns = [
name="report-weight-change-child", name="report-weight-change-child",
), ),
path( path(
"children/<str:slug>/reports/weight/<sex>/", "children/<str:slug>/reports/weight/boy/",
views.WeightChangeChildReport.as_view(), views.WeightChangeChildBoyReport.as_view(),
name="report-weight-change-child-sex", name="report-weight-change-child-boy",
),
path(
"children/<str:slug>/reports/weight/girl/",
views.WeightChangeChildGirlReport.as_view(),
name="report-weight-change-child-girl",
), ),
] ]

View File

@ -80,7 +80,7 @@ class DiaperChangeTypesChildReport(PermissionRequiredMixin, DetailView):
model = models.Child model = models.Child
permission_required = ("core.view_child",) permission_required = ("core.view_child",)
template_name = "reports/diaperchange_intervals.html" template_name = "reports/diaperchange_types.html"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(DiaperChangeTypesChildReport, self).get_context_data(**kwargs) context = super(DiaperChangeTypesChildReport, self).get_context_data(**kwargs)
@ -326,20 +326,38 @@ class WeightChangeChildReport(PermissionRequiredMixin, DetailView):
Graph of weight change over time. Graph of weight change over time.
""" """
model = models.Child def __init__(
permission_required = ("core.view_child",) self, sex=None, target_url="reports:report-weight-change-child"
template_name = "reports/weight_change.html" ) -> None:
self.model = models.Child
self.permission_required = ("core.view_child",)
self.template_name = "reports/weight_change.html"
self.sex = sex
self.target_url = target_url
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(WeightChangeChildReport, self).get_context_data(**kwargs) context = super(WeightChangeChildReport, self).get_context_data(**kwargs)
child = context["object"] child = context["object"]
birthday = child.birth_date birthday = child.birth_date
actual_weights = models.Weight.objects.filter(child=child) actual_weights = models.Weight.objects.filter(child=child)
percentile_weights = models.WeightPercentile.objects.filter( percentile_weights = models.WeightPercentile.objects.filter(sex=self.sex)
sex=self.kwargs.get("sex") context["target_url"] = self.target_url
)
if actual_weights: if actual_weights:
context["html"], context["js"] = graphs.weight_change( context["html"], context["js"] = graphs.weight_change(
actual_weights, percentile_weights, birthday actual_weights, percentile_weights, birthday
) )
return context return context
class WeightChangeChildBoyReport(WeightChangeChildReport):
def __init__(self):
super(WeightChangeChildBoyReport, self).__init__(
sex="boy", target_url="reports:report-weight-change-child-boy"
)
class WeightChangeChildGirlReport(WeightChangeChildReport):
def __init__(self):
super(WeightChangeChildGirlReport, self).__init__(
sex="girl", target_url="reports:report-weight-change-child-girl"
)

File diff suppressed because one or more lines are too long