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> aria-expanded="false"><i class="fa fa-bar-chart" aria-hidden="true"></i> Reports</button>
<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 %}
<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> <i class="fa fa-trash" aria-hidden="true"></i> Changes</a>
{% endif %} {% 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> </div>
</div> </div>

View File

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

View File

@ -7,7 +7,8 @@ from . import views
urlpatterns = [ urlpatterns = [
url(r'^reports/changes/(?P<slug>[^/.]+)/$', url(r'^reports/changes/(?P<slug>[^/.]+)/$',
views.DiaperChangesChildReport.as_view(), name='report-diaperchange'), views.DiaperChangesChildReport.as_view(),
url(r'^reports/(?P<slug>[^/.]+)/sleep/$', name='report-diaperchange-child'),
views.SleepReport.as_view(), name='report-sleep'), 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 self.javascript += javascript
class SleepReport(PermissionRequiredMixin, DetailView): class SleepChildReport(PermissionRequiredMixin, DetailView):
"""All sleep data for a child.""" """All sleep data for a child."""
model = Child model = Child
permission_required = ('core.view_child',) permission_required = ('core.view_child',)
template_name = 'reports/sleep.html' template_name = 'reports/sleep.html'
def get_context_data(self, **kwargs):
context = super(SleepReport, self).get_context_data(**kwargs)
return context