Add permissions checks to frontend.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-17 13:39:23 -04:00
parent 3bbfd012f4
commit d89fa9df11
8 changed files with 180 additions and 44 deletions

View File

@ -31,26 +31,58 @@
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item{% if request.path == '/' %} active{% endif %}">
<a class="nav-link" href="{% url 'index' %}"><i class="fa fa-dashboard" aria-hidden="true"></i> Dashboard</a>
</li>
<li class="nav-item{% if request.path == '/children/' %} active{% endif %}">
<a class="nav-link" href="{% url 'child-list' %}"><i class="fa fa-child" aria-hidden="true"></i> Children</a>
</li>
<li class="nav-item{% if request.path == '/changes/' %} active{% endif %}">
<a class="nav-link" href="{% url 'diaperchange-list' %}"><i class="fa fa-trash" aria-hidden="true"></i> Changes</a>
</li>
<li class="nav-item{% if request.path == '/feedings/' %} active{% endif %}">
<a class="nav-link" href="{% url 'feeding-list' %}"><i class="fa fa-spoon" aria-hidden="true"></i> Feedings</a>
</li>
<li class="nav-item{% if request.path == '/sleep/' %} active{% endif %}">
<a class="nav-link" href="{% url 'sleep-list' %}"><i class="fa fa-bed" aria-hidden="true"></i> Sleep</a>
</li>
<li class="nav-item{% if request.path == '/tummy-time/' %} active{% endif %}">
<a class="nav-link" href="{% url 'tummytime-list' %}"><i class="fa fa-smile-o" aria-hidden="true"></i> Tummy Time</a>
</li>
<li class="nav-item{% if request.path == '/notes/' %} active{% endif %}">
<a class="nav-link" href="{% url 'note-list' %}"><i class="fa fa-sticky-note" aria-hidden="true"></i> Notes</a>
<a class="nav-link" href="{% url 'index' %}">
<i class="fa fa-dashboard" aria-hidden="true"></i> Dashboard
</a>
</li>
{% if perms.core.view_child %}
<li class="nav-item{% if request.path == '/children/' %} active{% endif %}">
<a class="nav-link" href="{% url 'child-list' %}">
<i class="fa fa-child" aria-hidden="true"></i> Children
</a>
</li>
{% endif %}
{% if perms.core.view_diaperchange %}
<li class="nav-item{% if request.path == '/changes/' %} active{% endif %}">
<a class="nav-link" href="{% url 'diaperchange-list' %}">
<i class="fa fa-trash" aria-hidden="true"></i> Changes
</a>
</li>
{% endif %}
{% if perms.core.view_feeding %}
<li class="nav-item{% if request.path == '/feedings/' %} active{% endif %}">
<a class="nav-link" href="{% url 'feeding-list' %}">
<i class="fa fa-spoon" aria-hidden="true"></i> Feedings
</a>
</li>
{% endif %}
{% if perms.core.view_sleep %}
<li class="nav-item{% if request.path == '/sleep/' %} active{% endif %}">
<a class="nav-link" href="{% url 'sleep-list' %}">
<i class="fa fa-bed" aria-hidden="true"></i> Sleep
</a>
</li>
{% endif %}
{% if perms.core.view_tummytime %}
<li class="nav-item{% if request.path == '/tummy-time/' %} active{% endif %}">
<a class="nav-link" href="{% url 'tummytime-list' %}">
<i class="fa fa-smile-o" aria-hidden="true"></i> Tummy Time
</a>
</li>
{% endif %}
{% if perms.core.view_note %}
<li class="nav-item{% if request.path == '/notes/' %} active{% endif %}">
<a class="nav-link" href="{% url 'note-list' %}">
<i class="fa fa-sticky-note" aria-hidden="true"></i> Notes
</a>
</li>
{% endif %}
</ul>
</div>
</nav>
@ -60,11 +92,15 @@
<div class="col-lg-8 mb-4">
{% block content %}{% endblock %}
</div>
<div class="col-lg-2">
<h1>Timers</h1>
{% add_timer request.path %}
{% list_timers %}
</div>
{% if perms.core.view_timer %}
<div class="col-lg-2">
<h1>Timers</h1>
{% if perms.core.add_timer %}
{% add_timer request.path %}
{% endif %}
{% list_timers %}
</div>
{% endif %}
</div>
</div>

View File

@ -20,13 +20,24 @@
{% for child in object_list %}
<tr>
<th scope="row">{{ child.id }}</th>
<td><a href="{% url 'child-update' child.id %}">{{ child.first_name }}</a></td>
<td>{{ child.first_name }}</td>
<td>{{ child.last_name }}</td>
<td>{{ child.birth_date }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
<a href="{% url 'child-update' child.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="{% url 'child-delete' child.id %}" class="btn btn-danger"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
{% if perms.core.change_child %}
<a href="{% url 'child-update' child.id %}" class="btn btn-primary">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_child %}
<a href="{% url 'child-delete' child.id %}" class="btn btn-danger">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</td>
</tr>
@ -38,5 +49,11 @@
</tbody>
</table>
</div>
<a href="{% url 'child-add' %}" class="btn btn-sm btn-success"><i class="fa fa-child" aria-hidden="true"></i> Add a Child</a>
{% if perms.core.add_child %}
<a href="{% url 'child-add' %}" class="btn btn-sm btn-success">
<i class="fa fa-child" aria-hidden="true"></i> Add a Child
</a>
{% endif %}
{% endblock %}

View File

@ -29,8 +29,19 @@
<td>{{ change.color }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
<a href="{% url 'diaperchange-update' change.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="{% url 'diaperchange-delete' change.id %}" class="btn btn-danger"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
{% if perms.core.change_diaperchange %}
<a href="{% url 'diaperchange-update' change.id %}" class="btn btn-primary">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_diaperchange %}
<a href="{% url 'diaperchange-delete' change.id %}" class="btn btn-danger">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</td>
</tr>
@ -42,5 +53,11 @@
</tbody>
</table>
</div>
<a href="{% url 'diaperchange-add' %}" class="btn btn-sm btn-success"><i class="fa fa-trash" aria-hidden="true"></i> Add a Change</a>
{% if perms.core.add_diaperchange %}
<a href="{% url 'diaperchange-add' %}" class="btn btn-sm btn-success">
<i class="fa fa-trash" aria-hidden="true"></i> Add a Change
</a>
{% endif %}
{% endblock %}

View File

@ -31,8 +31,19 @@
<td>{{ feeding.amount }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
<a href="{% url 'feeding-update' feeding.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="{% url 'feeding-delete' feeding.id %}" class="btn btn-danger"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
{% if perms.core.change_feeding %}
<a href="{% url 'feeding-update' feeding.id %}" class="btn btn-primary">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_feeding %}
<a href="{% url 'feeding-delete' feeding.id %}" class="btn btn-danger">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</td>
</tr>
@ -44,5 +55,11 @@
</tbody>
</table>
</div>
<a href="{% url 'feeding-add' %}" class="btn btn-sm btn-success"><i class="fa fa-spoon" aria-hidden="true"></i> Add a Feeding</a>
{% if perms.core.add_feeding %}
<a href="{% url 'feeding-add' %}" class="btn btn-sm btn-success">
<i class="fa fa-spoon" aria-hidden="true"></i> Add a Feeding
</a>
{% endif %}
{% endblock %}

View File

@ -25,8 +25,19 @@
<td>{{ note.time }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
<a href="{% url 'note-update' note.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="{% url 'note-delete' note.id %}" class="btn btn-danger"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
{% if perms.core.change_note %}
<a href="{% url 'note-update' note.id %}" class="btn btn-primary">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_note %}
<a href="{% url 'note-delete' note.id %}" class="btn btn-danger">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</td>
</tr>
@ -38,5 +49,11 @@
</tbody>
</table>
</div>
<a href="{% url 'note-add' %}" class="btn btn-sm btn-success"><i class="fa fa-sticky-note" aria-hidden="true"></i> Add a Note</a>
{% if perms.core.add_note %}
<a href="{% url 'note-add' %}" class="btn btn-sm btn-success">
<i class="fa fa-sticky-note" aria-hidden="true"></i> Add a Note
</a>
{% endif %}
{% endblock %}

View File

@ -27,8 +27,19 @@
<td>{{ sleep.duration }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
<a href="{% url 'sleep-update' sleep.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="{% url 'sleep-delete' sleep.id %}" class="btn btn-danger"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
{% if perms.core.change_sleep %}
<a href="{% url 'sleep-update' sleep.id %}" class="btn btn-primary">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_sleep %}
<a href="{% url 'sleep-delete' sleep.id %}" class="btn btn-danger">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</td>
</tr>
@ -40,5 +51,11 @@
</tbody>
</table>
</div>
<a href="{% url 'sleep-add' %}" class="btn btn-sm btn-success"><i class="fa fa-bed" aria-hidden="true"></i> Add a Sleep Entry</a>
{% if perms.core.add_sleep %}
<a href="{% url 'sleep-add' %}" class="btn btn-sm btn-success">
<i class="fa fa-bed" aria-hidden="true"></i> Add a Sleep Entry
</a>
{% endif %}
{% endblock %}

View File

@ -29,8 +29,19 @@
<td>{{ tummytime.milestone }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
<a href="{% url 'tummytime-update' tummytime.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
<a href="{% url 'tummytime-delete' tummytime.id %}" class="btn btn-danger"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
{% if perms.core.change_tummytime %}
<a href="{% url 'tummytime-update' tummytime.id %}" class="btn btn-primary">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.core.delete_tummytime %}
<a href="{% url 'tummytime-delete' tummytime.id %}" class="btn btn-danger">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</td>
</tr>
@ -42,5 +53,9 @@
</tbody>
</table>
</div>
<a href="{% url 'tummytime-add' %}" class="btn btn-sm btn-success"><i class="fa fa-smile-o" aria-hidden="true"></i> Add a Tummy Time Entry</a>
{% if perms.core.add_tummytime %}
<a href="{% url 'tummytime-add' %}" class="btn btn-sm btn-success"><i class="fa fa-smile-o" aria-hidden="true"></i> Add a Tummy Time Entry</a>
{% endif %}
{% endblock %}

View File

@ -5,7 +5,7 @@
<h4 class="card-text">{{ timer.duration }}</h4>
</div>
<div class="card-footer text-muted small">
Started {{ timer.start }}
{{ timer.start }}
</div>
</div>
{% endfor %}