From 17f527035306ff2ea678430f418aa48dbcf1d4bc Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Sun, 6 Feb 2022 15:44:55 +0100 Subject: [PATCH] [WIP] Gymnast user --- README.md | 20 ++++ templates/followup/accidents/create.html | 16 ++- templates/followup/chronos/create.html | 12 ++- templates/followup/heightweight/create.html | 14 ++- templates/followup/learnedskills/create.html | 16 ++- templates/followup/mindstates/create.html | 22 ++-- templates/followup/plan/create.html | 14 ++- templates/followup/routinedone/create.html | 18 ++-- templates/followup/scores/create.html | 18 ++-- templates/locations/places/create.html | 4 +- templates/locations/places/details.html | 6 +- templates/locations/places/list.html | 43 +++++--- templates/objectives/routines/details.html | 26 ++--- templates/objectives/routines/list.html | 41 ++++--- templates/people/gymnasts/create.html | 7 ++ .../people/gymnasts/link_to_routine.html | 18 ++-- templates/people/gymnasts/list.html | 42 +++++--- templates/planning/events/details.html | 102 +++++++++++------- templates/planning/events/list.html | 21 +++- ultron/core/user_group_check.py | 6 ++ ultron/followup/forms.py | 9 ++ ultron/followup/views.py | 8 +- ultron/people/admin.py | 17 ++- ultron/people/forms.py | 32 ++++++ ultron/people/migrations/0002_gymnast_user.py | 21 ++++ ultron/people/models.py | 16 ++- ultron/people/views.py | 22 +++- ultron/tools/templatetags/has_group.py | 9 ++ 28 files changed, 428 insertions(+), 172 deletions(-) create mode 100644 ultron/core/user_group_check.py create mode 100644 ultron/people/migrations/0002_gymnast_user.py create mode 100644 ultron/tools/templatetags/has_group.py diff --git a/README.md b/README.md index ed011d993c..f658e45642 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,26 @@ ## Applications +### Right + +Il y a 3 types pe de droits : + + - Administrateur + - Entraineur (groupe `Trainer`) + - Gymnaste (groupe `Gymnast`) + +##### Administrateur + +Il peut tout faire. + +##### Entraîneur + +Peut tout faire sauf : + +- Gérer les skill +- Gérer les Pays +- Gérer les lieux + ### Skill ### Learned Skill diff --git a/templates/followup/accidents/create.html b/templates/followup/accidents/create.html index 52131a8f7c..f6c0ff0030 100644 --- a/templates/followup/accidents/create.html +++ b/templates/followup/accidents/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %}
@@ -19,11 +20,16 @@
- -
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + + {% endif %}
diff --git a/templates/followup/chronos/create.html b/templates/followup/chronos/create.html index 8981c32bae..5a419e0339 100644 --- a/templates/followup/chronos/create.html +++ b/templates/followup/chronos/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %}
@@ -21,9 +22,14 @@
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + + {% endif %}
diff --git a/templates/followup/heightweight/create.html b/templates/followup/heightweight/create.html index 3ece56d729..800d49dfe9 100644 --- a/templates/followup/heightweight/create.html +++ b/templates/followup/heightweight/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %}
@@ -20,10 +21,15 @@
-
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + + {% endif %}
diff --git a/templates/followup/learnedskills/create.html b/templates/followup/learnedskills/create.html index 56a1a1cb31..201e099612 100644 --- a/templates/followup/learnedskills/create.html +++ b/templates/followup/learnedskills/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %}
@@ -19,11 +20,16 @@
- -
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + + {% endif %}
diff --git a/templates/followup/mindstates/create.html b/templates/followup/mindstates/create.html index 14d924c81b..a3a15215dd 100644 --- a/templates/followup/mindstates/create.html +++ b/templates/followup/mindstates/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %}
@@ -12,14 +13,19 @@
{% csrf_token %}
- -
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} - + +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} + + {% endif %} + {% else %} + + {% endif %}
diff --git a/templates/followup/plan/create.html b/templates/followup/plan/create.html index 28fe170513..eca9fd9c50 100644 --- a/templates/followup/plan/create.html +++ b/templates/followup/plan/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %}
@@ -20,10 +21,15 @@
-
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + + {% endif %}
diff --git a/templates/followup/routinedone/create.html b/templates/followup/routinedone/create.html index 40c5ecc857..16de71a78e 100644 --- a/templates/followup/routinedone/create.html +++ b/templates/followup/routinedone/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static%} +{% load has_group %} {% block content %}
@@ -13,14 +14,15 @@ {% csrf_token %}
- -
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} - + +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + {% endif %}
diff --git a/templates/followup/scores/create.html b/templates/followup/scores/create.html index 5ef7b49f0b..2651a3eae8 100644 --- a/templates/followup/scores/create.html +++ b/templates/followup/scores/create.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load has_group %} {% block content %} @@ -13,14 +14,15 @@ {% csrf_token %}
- -
- {{ form.gymnast }} - {{ form.gymnast_related }} - {% if form.gymnast.errors %} - + +
+ {% if request.user|has_group:"Trainer" %} + {{ form.gymnast }} + {{ form.gymnast_related }} + {% if form.gymnast.errors %} {% for error in form.gymnast.errors %}{{error}}{% endfor %}{% endif %} + {% else %} + + {% endif %}
diff --git a/templates/locations/places/create.html b/templates/locations/places/create.html index 9693ecb820..5418fe087b 100644 --- a/templates/locations/places/create.html +++ b/templates/locations/places/create.html @@ -35,7 +35,7 @@
{{ form.postal }} {% if form.postal.errors %} {% for error in form.postal.errors %}{{error}}{% endfor %}{% endif %} -
s +
{{ form.city }} {% if form.city.errors %} {% for error in form.city.errors %}{{error}}{% endfor %}{% endif %} @@ -60,7 +60,7 @@
{% endif %}
- +
diff --git a/templates/locations/places/details.html b/templates/locations/places/details.html index 5073cb751a..48b5aedaff 100644 --- a/templates/locations/places/details.html +++ b/templates/locations/places/details.html @@ -8,15 +8,15 @@

{{ place.name }}

-
+
-
+

{{ place.address }}
{{ place.postal }} {{ place.city }}
{{ place.country.nameus }} -

+

{% if place.nbkm %}{{ place.nbkm }}km
{% endif %} diff --git a/templates/locations/places/list.html b/templates/locations/places/list.html index b4ca617bdf..5a4a7a2c31 100644 --- a/templates/locations/places/list.html +++ b/templates/locations/places/list.html @@ -1,4 +1,5 @@ {% extends "listing.html" %} +{% load has_group %} {% block datacontent %}
@@ -9,11 +10,13 @@
- - - + {% if request.user|has_group:"Trainer" %} + + + + {% endif %}
@@ -24,7 +27,9 @@ - + {% if request.user|has_group:"Trainer" %} + + {% endif %} @@ -37,11 +42,13 @@ {% for place in place_list %} - + {% if request.user|has_group:"Trainer" %} + + {% endif %} @@ -65,11 +72,17 @@
Name Address Zip
- - - - + + + + {{ place.name }} {{ place.address }} {{ place.postal}}