3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-12-25 00:13:46 +00:00

Fix permissions

This commit is contained in:
Yoann Pétri 2018-12-23 23:17:08 +01:00
parent 613c2b8348
commit 885f2c2af8
2 changed files with 45 additions and 7 deletions

View file

@ -2,13 +2,22 @@
{% block entete %}Gestion des produits{% endblock %} {% block entete %}Gestion des produits{% endblock %}
{% block navbar%} {% block navbar%}
<ul> <ul>
{% if perms.gestion.add_product or perms.gestion.view_product %}
<li><a href="#first">Produits</a></li> <li><a href="#first">Produits</a></li>
{% endif %}
{% if perms.gestion.add_keg or perms.gestion.open_keg or perms.gestion.close_keg or perms.gestion.view_keg %}
<li><a href="#second">Futs</a></li> <li><a href="#second">Futs</a></li>
{% endif %}
{% if perms.gestion.add_menu or perms.gestion.view_menu %}
<li><a href="#third">Menus</a></li> <li><a href="#third">Menus</a></li>
{% endif %}
{% if perms.gestion.add_pinte or perms.gestion.change_pinte or perms.gestion.view_pinte or perms.auth.view_user %}
<li><a href="#fourth">Pintes</a></li> <li><a href="#fourth">Pintes</a></li>
{% endif %}
</ul> </ul>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if perms.gestion.add_product or perms.gestion.view_product %}
<section id="first" class="main"> <section id="first" class="main">
<header class="major"> <header class="major">
<h2>Produits</h2> <h2>Produits</h2>
@ -24,6 +33,8 @@
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if perms.gestion.add_keg or perms.gestion.open_keg or perms.gestion.close_keg or perms.gestion.view_keg %}
<section id="second" class="main"> <section id="second" class="main">
<header class="major"> <header class="major">
<h2>Futs</h2> <h2>Futs</h2>
@ -44,6 +55,8 @@
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if perms.gestion.add_menu or perms.gestion.view_menu %}
<section id="third" class="main"> <section id="third" class="main">
<header class="major"> <header class="major">
<h2>Menus</h2> <h2>Menus</h2>
@ -59,6 +72,8 @@
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if perms.gestion.add_pinte or perms.gestion.change_pinte or perms.gestion.view_pinte or perms.auth.view_user %}
<section id="fourth" class="main"> <section id="fourth" class="main">
<header class="major"> <header class="major">
<h2>Pintes</h2> <h2>Pintes</h2>
@ -79,4 +94,5 @@
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% endblock %} {% endblock %}

View file

@ -2,15 +2,28 @@
{% block entete %}Gestion des utilisateurs{% endblock %} {% block entete %}Gestion des utilisateurs{% endblock %}
{% block navbar%} {% block navbar%}
<ul> <ul>
{% if perms.auth.add_user or perms.auth.view_user %}
<li><a href="#first">Utilisateurs</a></li> <li><a href="#first">Utilisateurs</a></li>
{% endif %}
{% if perms.auth.add_group or perms.auth.view_group %}
<li><a href="#second">Groupes</a></li> <li><a href="#second">Groupes</a></li>
{% endif %}
{% if request.user.is_staff %}
<li><a href="#third">Admins</a></li> <li><a href="#third">Admins</a></li>
{% endif %}
{% if request.user.is_superuser %}
<li><a href="#fourth">Superusers</a></li> <li><a href="#fourth">Superusers</a></li>
{% endif %}
{% if perms.users.add_school or perms.users.view_school %}
<li><a href="#fifth">Écoles</a></li> <li><a href="#fifth">Écoles</a></li>
{% endif %}
{% if perms.aut.view_user %}
<li><a href="#sixth">Exportation de données</a></li> <li><a href="#sixth">Exportation de données</a></li>
{% endif %}
</ul> </ul>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if perms.auth.add_user or perms.auth.view_user %}
<section id="first" class="main"> <section id="first" class="main">
<header class="major"> <header class="major">
<h2>Utilisateurs</h2> <h2>Utilisateurs</h2>
@ -26,18 +39,24 @@
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if perms.auth.add_group or perms.auth.view_group %}
<section id="second" class="main"> <section id="second" class="main">
<header class="major"> <header class="major">
<h2>Groupes</h2> <h2>Groupes</h2>
</header> </header>
Actions possibles : Actions possibles :
<ul> <ul>
{% if perms.auth.view_group %} {% if perms.auth.add_group %}
<li><a href="{% url 'users:createGroup' %}">Ajouter un groupe de droit</a></li> <li><a href="{% url 'users:createGroup' %}">Ajouter un groupe de droit</a></li>
{% endif %}
{% if perms.auth.view_group %}
<li><a href="{% url 'users:groupsIndex' %}">Lister les groupes de droits</a></li> <li><a href="{% url 'users:groupsIndex' %}">Lister les groupes de droits</a></li>
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if request.user.is_staff %}
<section id="third" class="main"> <section id="third" class="main">
<header class="major"> <header class="major">
<h2>Admins</h2> <h2>Admins</h2>
@ -45,12 +64,12 @@
Les admins ont accès à l'interface admin.<br> Les admins ont accès à l'interface admin.<br>
Actions possibles : Actions possibles :
<ul> <ul>
{% if request.user.is_staff %}
<li><a href="{% url 'users:addAdmin' %}">Ajouter un admin</a></li> <li><a href="{% url 'users:addAdmin' %}">Ajouter un admin</a></li>
<li><a href="{% url 'users:adminsIndex' %}">Lister les admins</a></li> <li><a href="{% url 'users:adminsIndex' %}">Lister les admins</a></li>
{% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if request.user.is_superuser %}
<section id="fourth" class="main"> <section id="fourth" class="main">
<header class="major"> <header class="major">
<h2>Superusers</h2> <h2>Superusers</h2>
@ -58,26 +77,28 @@
Attention : les superusers bypass toutes les vérifications de permissions.<br> Attention : les superusers bypass toutes les vérifications de permissions.<br>
Actions possibles : Actions possibles :
<ul> <ul>
{% if request.user.is_superuser %}
<li><a href="{% url 'users:addSuperuser' %}">Ajouter un superuser</a></li> <li><a href="{% url 'users:addSuperuser' %}">Ajouter un superuser</a></li>
<li><a href="{% url 'users:superusersIndex' %}">Lister les superuser</a></li> <li><a href="{% url 'users:superusersIndex' %}">Lister les superuser</a></li>
{% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if perms.users.add_school or perms.users.view_school %}
<section id="fifth" class="main"> <section id="fifth" class="main">
<header class="major"> <header class="major">
<h2>Écoles</h2> <h2>Écoles</h2>
</header> </header>
Actions possibles : Actions possibles :
<ul> <ul>
{% if perms.gestion.add_school %} {% if perms.users.add_school %}
<li><a href="{% url 'users:createSchool' %}">Ajouter une école</a></li> <li><a href="{% url 'users:createSchool' %}">Ajouter une école</a></li>
{% endif %} {% endif %}
{% if perms.gestion.view_school %} {% if perms.users.view_school %}
<li><a href="{% url 'users:schoolsIndex' %}">Lister les écoles</a></li> <li><a href="{% url 'users:schoolsIndex' %}">Lister les écoles</a></li>
{% endif %} {% endif %}
</ul> </ul>
</section> </section>
{% endif %}
{% if perms.auth.view_user %}
<section id="sixth" class="main"> <section id="sixth" class="main">
<header class="major"> <header class="major">
<h2>Exportation de données</h2> <h2>Exportation de données</h2>
@ -88,4 +109,5 @@
<button class="button" target="_blank">Exporter au format csv</button> <button class="button" target="_blank">Exporter au format csv</button>
</form> </form>
</section> </section>
{% endif %}
{% endblock %} {% endblock %}