Add a Child detail view.

This commit is contained in:
Christopher Charbonneau Wells 2017-10-20 15:23:26 -04:00
parent c50ccca1bb
commit 201283221c
3 changed files with 59 additions and 5 deletions

View File

@ -0,0 +1,51 @@
{% extends 'babyblotter/page.html' %}
{% block title %}{{ object }}{% endblock %}
{% block content %}
<div class="jumbotron text-center">
<div class="display-3">{{ object }}</div>
<p class="lead">
Born <span class="text-secondary">{{ object.birth_date }}</span><br/>
Age <span class="text-secondary">{{ object.birth_date|timesince }}</span>
</p>
<div class="btn-group btn-group-lg center-block" role="group" aria-label="Timer actions">
{% if perms.core.view_child %}
<a href="{% url 'dashboard-child' object.slug %}" class="btn btn-success">
<i class="icon icon-dashboard" aria-hidden="true"></i>
</a>
{% endif %}
<div class="btn-group" role="group">
<button id="reports-dropdown"
class="btn btn-primary dropdown-toggle"
type="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"><i class="icon icon-graph" aria-hidden="true"></i></button>
<div class="dropdown-menu" aria-labelledby="reports-dropdown">
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-types-child' object.slug %}">Diaper Change Types</a>
<a class="dropdown-item" href="{% url 'reports:report-diaperchange-lifetimes-child' object.slug %}">Diaper Lifetimes</a>
<a class="dropdown-item" href="{% url 'reports:report-sleep-pattern-child' object.slug %}">Sleep Pattern</a>
<a class="dropdown-item" href="{% url 'reports:report-sleep-totals-child' object.slug %}">Sleep Totals</a>
<a class="dropdown-item" href="{% url 'reports:report-timeline-child' object.slug %}">Timeline</a>
</div>
</div>
{% if perms.core.change_child %}
<a class="btn btn-warning"
href="{% url 'child-update' object.slug %}"
role="button"><i class="icon icon-update" aria-hidden="true"></i></a>
{% endif %}
{% if perms.core.delete_child %}
<a class="btn btn-danger"
href="{% url 'child-delete' object.slug %}"
role="button"><i class="icon icon-delete" aria-hidden="true"></i></a>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -8,12 +8,10 @@ from . import views
urlpatterns = [
url(r'^children/$', views.ChildList.as_view(), name='child-list'),
url(r'^children/add/$', views.ChildAdd.as_view(), name='child-add'),
url(r'^children/(?P<pk>[0-9]+)/$', views.ChildUpdate.as_view(),
url(r'^children/(?P<slug>[^/.]+)/$', views.ChildDetail.as_view(),
name='child'),
url(r'^children/(?P<slug>[^/.]+)/edit$', views.ChildUpdate.as_view(),
name='child-update'),
url(r'^children/(?P<slug>[^/.]+)/$', views.ChildUpdate.as_view(),
name='child-update'),
url(r'^children/(?P<pk>[0-9]+)/delete/$', views.ChildDelete.as_view(),
name='child-delete'),
url(r'^children/(?P<slug>[^/.]+)/delete/$', views.ChildDelete.as_view(),
name='child-delete'),

View File

@ -26,6 +26,11 @@ class ChildAdd(PermissionRequiredMixin, CreateView):
success_url = '/children'
class ChildDetail(PermissionRequiredMixin, DetailView):
model = Child
permission_required = ('core.view_child',)
class ChildUpdate(PermissionRequiredMixin, UpdateView):
model = Child
permission_required = ('core.change_child',)