From e77c2a5639d67cac40a24e948de79cc547d7aaca Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Wed, 13 Sep 2017 11:25:12 -0400 Subject: [PATCH] Refactor naming of current reports. --- dashboard/templates/dashboard/child.html | 4 ++-- reports/graphs.py | 4 ++-- ...perchange.html => diaperchange_types.html} | 0 .../{sleep.html => sleep_pattern.html} | 0 reports/urls.py | 11 +++++----- reports/views.py | 22 +++++++++---------- 6 files changed, 21 insertions(+), 20 deletions(-) rename reports/templates/reports/{diaperchange.html => diaperchange_types.html} (100%) rename reports/templates/reports/{sleep.html => sleep_pattern.html} (100%) diff --git a/dashboard/templates/dashboard/child.html b/dashboard/templates/dashboard/child.html index 1eeb4311..0613f5e2 100644 --- a/dashboard/templates/dashboard/child.html +++ b/dashboard/templates/dashboard/child.html @@ -18,11 +18,11 @@ diff --git a/reports/graphs.py b/reports/graphs.py index 26ab2ac1..b569d51f 100644 --- a/reports/graphs.py +++ b/reports/graphs.py @@ -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'] = 'Sleep Patterns
{}'.format(child) + layout_args['title'] = 'Sleep Pattern
{}'.format(child) layout_args['height'] = 600 layout_args['xaxis']['title'] = 'Date' diff --git a/reports/templates/reports/diaperchange.html b/reports/templates/reports/diaperchange_types.html similarity index 100% rename from reports/templates/reports/diaperchange.html rename to reports/templates/reports/diaperchange_types.html diff --git a/reports/templates/reports/sleep.html b/reports/templates/reports/sleep_pattern.html similarity index 100% rename from reports/templates/reports/sleep.html rename to reports/templates/reports/sleep_pattern.html diff --git a/reports/urls.py b/reports/urls.py index 59434bcf..5cc4343f 100644 --- a/reports/urls.py +++ b/reports/urls.py @@ -6,9 +6,10 @@ from django.conf.urls import url from . import views urlpatterns = [ - url(r'^reports/changes/(?P[^/.]+)/$', - views.DiaperChangesChildReport.as_view(), - name='report-diaperchange-child'), - url(r'^reports/sleep/(?P[^/.]+)$', - views.SleepChildReport.as_view(), name='report-sleep-child'), + url(r'^reports/changes/types/(?P[^/.]+)/$', + views.DiaperChangeTypesChildReport.as_view(), + name='report-diaperchange-types-child'), + url(r'^reports/sleep/pattern/(?P[^/.]+)$', + views.SleepPatternChildReport.as_view(), + name='report-sleep-pattern-child'), ] diff --git a/reports/views.py b/reports/views.py index c252c1d8..c84867d3 100644 --- a/reports/views.py +++ b/reports/views.py @@ -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