mirror of https://github.com/snachodog/mybuddy.git
Refactor naming of current reports.
This commit is contained in:
parent
6cfbba5f81
commit
e77c2a5639
|
@ -18,11 +18,11 @@
|
|||
<div class="dropdown-menu" aria-labelledby="reports-dropdown">
|
||||
{% if perms.core.view_diaperchange %}
|
||||
<h6 class="dropdown-header"><i class="fa fa-trash" aria-hidden="true"></i> Diaper Changes</h6>
|
||||
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-child' object.slug %}">Change Types</a>
|
||||
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-types-child' object.slug %}">Change Types</a>
|
||||
{% endif %}
|
||||
{% if perms.core.view_sleep %}
|
||||
<h6 class="dropdown-header"><i class="fa fa-bed" aria-hidden="true"></i> Sleep</h6>
|
||||
<a class="dropdown-item" href="{% url 'reports:report-sleep-child' object.slug %}">Sleep Patterns</a>
|
||||
<a class="dropdown-item" href="{% url 'reports:report-sleep-pattern-child' object.slug %}">Sleep Pattern</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -73,7 +73,7 @@ def sleep_amount(child):
|
|||
totals[start_date] += instance.duration
|
||||
|
||||
|
||||
def sleep_times(child):
|
||||
def sleep_pattern(child):
|
||||
"""Create a graph showing blocked out periods of sleep during each day."""
|
||||
instances = Sleep.objects.filter(child=child).order_by('start')
|
||||
y_df = pd.DataFrame()
|
||||
|
@ -173,7 +173,7 @@ def sleep_times(child):
|
|||
|
||||
layout_args['barmode'] = 'stack'
|
||||
layout_args['hovermode'] = 'closest'
|
||||
layout_args['title'] = '<b>Sleep Patterns</b><br>{}'.format(child)
|
||||
layout_args['title'] = '<b>Sleep Pattern</b><br>{}'.format(child)
|
||||
layout_args['height'] = 600
|
||||
|
||||
layout_args['xaxis']['title'] = 'Date'
|
||||
|
|
|
@ -6,9 +6,10 @@ from django.conf.urls import url
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^reports/changes/(?P<slug>[^/.]+)/$',
|
||||
views.DiaperChangesChildReport.as_view(),
|
||||
name='report-diaperchange-child'),
|
||||
url(r'^reports/sleep/(?P<slug>[^/.]+)$',
|
||||
views.SleepChildReport.as_view(), name='report-sleep-child'),
|
||||
url(r'^reports/changes/types/(?P<slug>[^/.]+)/$',
|
||||
views.DiaperChangeTypesChildReport.as_view(),
|
||||
name='report-diaperchange-types-child'),
|
||||
url(r'^reports/sleep/pattern/(?P<slug>[^/.]+)$',
|
||||
views.SleepPatternChildReport.as_view(),
|
||||
name='report-sleep-pattern-child'),
|
||||
]
|
||||
|
|
|
@ -6,35 +6,35 @@ from django.views.generic.detail import DetailView
|
|||
|
||||
from core.models import Child
|
||||
|
||||
from .graphs import diaperchange_types, sleep_times
|
||||
from .graphs import diaperchange_types, sleep_pattern
|
||||
|
||||
|
||||
class DiaperChangesChildReport(PermissionRequiredMixin, DetailView):
|
||||
"""Diaper change information by type."""
|
||||
class DiaperChangeTypesChildReport(PermissionRequiredMixin, DetailView):
|
||||
"""Graph of diaper changes by day and type."""
|
||||
model = Child
|
||||
permission_required = ('core.view_child',)
|
||||
template_name = 'reports/diaperchange.html'
|
||||
template_name = 'reports/diaperchange_types.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DiaperChangesChildReport, self).get_context_data(**kwargs)
|
||||
context = super(DiaperChangeTypesChildReport, self).get_context_data(**kwargs)
|
||||
child = context['object']
|
||||
context['html'], context['javascript'] = diaperchange_types(child)
|
||||
return context
|
||||
|
||||
|
||||
class SleepChildReport(PermissionRequiredMixin, DetailView):
|
||||
"""All sleep times by date."""
|
||||
class SleepPatternChildReport(PermissionRequiredMixin, DetailView):
|
||||
"""Graph of sleep pattern comparing sleep to wake times by day."""
|
||||
model = Child
|
||||
permission_required = ('core.view_child',)
|
||||
template_name = 'reports/sleep.html'
|
||||
template_name = 'reports/sleep_pattern.html'
|
||||
|
||||
def __init__(self):
|
||||
super(SleepChildReport, self).__init__()
|
||||
super(SleepPatternChildReport, self).__init__()
|
||||
self.html = ''
|
||||
self.javascript = ''
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(SleepChildReport, self).get_context_data(**kwargs)
|
||||
context = super(SleepPatternChildReport, self).get_context_data(**kwargs)
|
||||
child = context['object']
|
||||
context['html'], context['javascript'] = sleep_times(child)
|
||||
context['html'], context['javascript'] = sleep_pattern(child)
|
||||
return context
|
||||
|
|
Loading…
Reference in New Issue