From d89fa9df11d21b1119b45235bbdba54011f22cc2 Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Thu, 17 Aug 2017 13:39:23 -0400 Subject: [PATCH] Add permissions checks to frontend. --- core/templates/core/base.html | 84 +++++++++++++++------- core/templates/core/child_list.html | 25 +++++-- core/templates/core/diaperchange_list.html | 23 +++++- core/templates/core/feeding_list.html | 23 +++++- core/templates/core/note_list.html | 23 +++++- core/templates/core/sleep_list.html | 23 +++++- core/templates/core/tummytime_list.html | 21 +++++- core/templates/timer_list.html | 2 +- 8 files changed, 180 insertions(+), 44 deletions(-) diff --git a/core/templates/core/base.html b/core/templates/core/base.html index 9b4ace4f..40560905 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -31,26 +31,58 @@ @@ -60,11 +92,15 @@
{% block content %}{% endblock %}
-
-

Timers

- {% add_timer request.path %} - {% list_timers %} -
+ {% if perms.core.view_timer %} +
+

Timers

+ {% if perms.core.add_timer %} + {% add_timer request.path %} + {% endif %} + {% list_timers %} +
+ {% endif %} diff --git a/core/templates/core/child_list.html b/core/templates/core/child_list.html index c139b117..8eb21e1b 100644 --- a/core/templates/core/child_list.html +++ b/core/templates/core/child_list.html @@ -20,13 +20,24 @@ {% for child in object_list %} {{ child.id }} - {{ child.first_name }} + {{ child.first_name }} {{ child.last_name }} {{ child.birth_date }}
- - + + {% if perms.core.change_child %} + + + + {% endif %} + + {% if perms.core.delete_child %} + + + + {% endif %} +
@@ -38,5 +49,11 @@ - Add a Child + + {% if perms.core.add_child %} + + Add a Child + + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/core/templates/core/diaperchange_list.html b/core/templates/core/diaperchange_list.html index af2af162..c182ddbb 100644 --- a/core/templates/core/diaperchange_list.html +++ b/core/templates/core/diaperchange_list.html @@ -29,8 +29,19 @@ {{ change.color }}
- - + + {% if perms.core.change_diaperchange %} + + + + {% endif %} + + {% if perms.core.delete_diaperchange %} + + + + {% endif %} +
@@ -42,5 +53,11 @@ - Add a Change + + {% if perms.core.add_diaperchange %} + + Add a Change + + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/core/templates/core/feeding_list.html b/core/templates/core/feeding_list.html index 1e434319..daddd90a 100644 --- a/core/templates/core/feeding_list.html +++ b/core/templates/core/feeding_list.html @@ -31,8 +31,19 @@ {{ feeding.amount }}
- - + + {% if perms.core.change_feeding %} + + + + {% endif %} + + {% if perms.core.delete_feeding %} + + + + {% endif %} +
@@ -44,5 +55,11 @@ - Add a Feeding + + {% if perms.core.add_feeding %} + + Add a Feeding + + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/core/templates/core/note_list.html b/core/templates/core/note_list.html index aa0789ff..255d8219 100644 --- a/core/templates/core/note_list.html +++ b/core/templates/core/note_list.html @@ -25,8 +25,19 @@ {{ note.time }}
- - + + {% if perms.core.change_note %} + + + + {% endif %} + + {% if perms.core.delete_note %} + + + + {% endif %} +
@@ -38,5 +49,11 @@ - Add a Note + + {% if perms.core.add_note %} + + Add a Note + + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/core/templates/core/sleep_list.html b/core/templates/core/sleep_list.html index fbf8345c..b5b679c3 100644 --- a/core/templates/core/sleep_list.html +++ b/core/templates/core/sleep_list.html @@ -27,8 +27,19 @@ {{ sleep.duration }}
- - + + {% if perms.core.change_sleep %} + + + + {% endif %} + + {% if perms.core.delete_sleep %} + + + + {% endif %} +
@@ -40,5 +51,11 @@ - Add a Sleep Entry + + {% if perms.core.add_sleep %} + + Add a Sleep Entry + + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/core/templates/core/tummytime_list.html b/core/templates/core/tummytime_list.html index 9028d8a8..1fd15c75 100644 --- a/core/templates/core/tummytime_list.html +++ b/core/templates/core/tummytime_list.html @@ -29,8 +29,19 @@ {{ tummytime.milestone }}
- - + + {% if perms.core.change_tummytime %} + + + + {% endif %} + + {% if perms.core.delete_tummytime %} + + + + {% endif %} +
@@ -42,5 +53,9 @@ - Add a Tummy Time Entry + + {% if perms.core.add_tummytime %} + Add a Tummy Time Entry + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/core/templates/timer_list.html b/core/templates/timer_list.html index 4e44b5ec..c05833c8 100644 --- a/core/templates/timer_list.html +++ b/core/templates/timer_list.html @@ -5,7 +5,7 @@

{{ timer.duration }}

{% endfor %} \ No newline at end of file