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