Prepare for a sleep reports page.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-25 08:08:02 -04:00
parent 2fdee5785b
commit ae71c5933e
4 changed files with 21 additions and 13 deletions

View File

@ -17,9 +17,13 @@
aria-expanded="false"><i class="fa fa-bar-chart" aria-hidden="true"></i> Reports</button>
<div class="dropdown-menu" aria-labelledby="reports-dropdown">
{% if perms.core.view_diaperchange %}
<a class="dropdown-item" href="{% url 'reports:report-diaperchange' object.slug %}">
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-child' object.slug %}">
<i class="fa fa-trash" aria-hidden="true"></i> Changes</a>
{% endif %}
{% if perms.core.view_sleep %}
<a class="dropdown-item" href="{% url 'reports:report-sleep-child' object.slug %}">
<i class="fa fa-bed" aria-hidden="true"></i> Sleep</a>
{% endif %}
</div>
</div>
</div>

View File

@ -1,12 +1,19 @@
{% extends 'reports/report_base.html' %}
{% block title %}Sleep Report - {{ object }}{% endblock %}
{% block title %}Sleep Reports - {{ object }}{% endblock %}
{% block content %}
<div>
Sleep report for {{ object }}.
<div class="jumbotron jumbotron-fluid text-center">
<h1 class="display-3">Sleep Reports</h1>
<h2 class="text-muted">{{ object }}</h2>
</div>
<div class="container-fluid">
{{ html|safe }}
</div>
Test
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -7,7 +7,8 @@ from . import views
urlpatterns = [
url(r'^reports/changes/(?P<slug>[^/.]+)/$',
views.DiaperChangesChildReport.as_view(), name='report-diaperchange'),
url(r'^reports/(?P<slug>[^/.]+)/sleep/$',
views.SleepReport.as_view(), name='report-sleep'),
views.DiaperChangesChildReport.as_view(),
name='report-diaperchange-child'),
url(r'^reports/sleep/(?P<slug>[^/.]+)$',
views.SleepChildReport.as_view(), name='report-sleep-child'),
]

View File

@ -76,12 +76,8 @@ class DiaperChangesChildReport(PermissionRequiredMixin, DetailView):
self.javascript += javascript
class SleepReport(PermissionRequiredMixin, DetailView):
class SleepChildReport(PermissionRequiredMixin, DetailView):
"""All sleep data for a child."""
model = Child
permission_required = ('core.view_child',)
template_name = 'reports/sleep.html'
def get_context_data(self, **kwargs):
context = super(SleepReport, self).get_context_data(**kwargs)
return context