mirror of https://github.com/snachodog/mybuddy.git
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:
parent
7747ae9023
commit
1063d39af0
|
@ -5,6 +5,4 @@
|
|||
|
||||
{% block breadcrumbs %}
|
||||
<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 %}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{% load breadcrumb i18n %}
|
||||
|
||||
<li class="breadcrumb-item font-weight-bold">
|
||||
{% child_quick_switch object target_url %}
|
||||
</li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'reports:report-list' object.slug %}">{% trans "Reports" %}</a></li>
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<li class="breadcrumb-item font-weight-bold">
|
||||
{% child_quick_switch object target_url %}
|
||||
</li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'reports:report-list' object.slug %}">{% trans "Reports" %}</a></li>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
{% block breadcrumbs %}
|
||||
{{ 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>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
{% block breadcrumbs %}
|
||||
{{ 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>
|
||||
{% endblock %}
|
||||
|
|
|
@ -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-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-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-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-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-girl' object.slug %}" class="list-group-item list-group-item-action">{% trans "WHO Weight Percentiles for Girls in kg" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
{% block breadcrumbs %}
|
||||
{{ 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>
|
||||
{% endblock %}
|
|
@ -92,8 +92,13 @@ urlpatterns = [
|
|||
name="report-weight-change-child",
|
||||
),
|
||||
path(
|
||||
"children/<str:slug>/reports/weight/<sex>/",
|
||||
views.WeightChangeChildReport.as_view(),
|
||||
name="report-weight-change-child-sex",
|
||||
"children/<str:slug>/reports/weight/boy/",
|
||||
views.WeightChangeChildBoyReport.as_view(),
|
||||
name="report-weight-change-child-boy",
|
||||
),
|
||||
path(
|
||||
"children/<str:slug>/reports/weight/girl/",
|
||||
views.WeightChangeChildGirlReport.as_view(),
|
||||
name="report-weight-change-child-girl",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -80,7 +80,7 @@ class DiaperChangeTypesChildReport(PermissionRequiredMixin, DetailView):
|
|||
|
||||
model = models.Child
|
||||
permission_required = ("core.view_child",)
|
||||
template_name = "reports/diaperchange_intervals.html"
|
||||
template_name = "reports/diaperchange_types.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DiaperChangeTypesChildReport, self).get_context_data(**kwargs)
|
||||
|
@ -326,20 +326,38 @@ class WeightChangeChildReport(PermissionRequiredMixin, DetailView):
|
|||
Graph of weight change over time.
|
||||
"""
|
||||
|
||||
model = models.Child
|
||||
permission_required = ("core.view_child",)
|
||||
template_name = "reports/weight_change.html"
|
||||
def __init__(
|
||||
self, sex=None, target_url="reports:report-weight-change-child"
|
||||
) -> 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):
|
||||
context = super(WeightChangeChildReport, self).get_context_data(**kwargs)
|
||||
child = context["object"]
|
||||
birthday = child.birth_date
|
||||
actual_weights = models.Weight.objects.filter(child=child)
|
||||
percentile_weights = models.WeightPercentile.objects.filter(
|
||||
sex=self.kwargs.get("sex")
|
||||
)
|
||||
percentile_weights = models.WeightPercentile.objects.filter(sex=self.sex)
|
||||
context["target_url"] = self.target_url
|
||||
if actual_weights:
|
||||
context["html"], context["js"] = graphs.weight_change(
|
||||
actual_weights, percentile_weights, birthday
|
||||
)
|
||||
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
Loading…
Reference in New Issue