diff --git a/cotisations/templates/cotisations/aff_article.html b/cotisations/templates/cotisations/aff_article.html index d39bc312..c14dbae2 100644 --- a/cotisations/templates/cotisations/aff_article.html +++ b/cotisations/templates/cotisations/aff_article.html @@ -14,7 +14,7 @@ {{ article.prix }} {{ article.cotisation }} {{ article.duration }} - Editer + {% if is_trez %} Editer{% endif %} {% endfor %} diff --git a/cotisations/templates/cotisations/aff_banque.html b/cotisations/templates/cotisations/aff_banque.html index 4db16bdd..9fb0736d 100644 --- a/cotisations/templates/cotisations/aff_banque.html +++ b/cotisations/templates/cotisations/aff_banque.html @@ -8,7 +8,7 @@ {% for banque in banque_list %} {{ banque.name }} - Editer + {% if is_trez %} Editer{% endif %} {% endfor %} diff --git a/cotisations/templates/cotisations/aff_paiement.html b/cotisations/templates/cotisations/aff_paiement.html index 1bfec970..a2b8f11f 100644 --- a/cotisations/templates/cotisations/aff_paiement.html +++ b/cotisations/templates/cotisations/aff_paiement.html @@ -8,7 +8,7 @@ {% for paiement in paiement_list %} {{ paiement.moyen }} - Editer + {% if is_trez %} Editer{% endif %} {% endfor %} diff --git a/cotisations/templates/cotisations/index_article.html b/cotisations/templates/cotisations/index_article.html index 0f3011a5..c92fdf8f 100644 --- a/cotisations/templates/cotisations/index_article.html +++ b/cotisations/templates/cotisations/index_article.html @@ -5,8 +5,10 @@ {% block content %}

Liste des types d'articles

+ {% if is_trez %} Ajouter un type d'articles Supprimer un ou plusieurs types d'articles + {% endif %} {% include "cotisations/aff_article.html" with article_list=article_list %}

diff --git a/cotisations/templates/cotisations/index_banque.html b/cotisations/templates/cotisations/index_banque.html index cad36320..12802ad4 100644 --- a/cotisations/templates/cotisations/index_banque.html +++ b/cotisations/templates/cotisations/index_banque.html @@ -6,7 +6,9 @@ {% block content %}

Liste des banques

Ajouter une banque + {% if is_trez %} Supprimer une ou plusieurs banques + {% endif %} {% include "cotisations/aff_banque.html" with banque_list=banque_list %}

diff --git a/cotisations/templates/cotisations/index_paiement.html b/cotisations/templates/cotisations/index_paiement.html index 5163165e..bc6204cd 100644 --- a/cotisations/templates/cotisations/index_paiement.html +++ b/cotisations/templates/cotisations/index_paiement.html @@ -5,8 +5,10 @@ {% block content %}

Liste des types de paiements

+ {% if is_trez %} Ajouter un type de paiement Supprimer un ou plusieurs types de paiements + {% endif %} {% include "cotisations/aff_paiement.html" with paiement_list=paiement_list %}

diff --git a/cotisations/views.py b/cotisations/views.py index a196af61..738a0c30 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -167,7 +167,6 @@ def del_paiement(request): return form({'factureform': paiement}, 'cotisations/facture.html', request) @login_required -@permission_required('trésorier') def add_banque(request): banque = BanqueForm(request.POST or None) if banque.is_valid(): @@ -208,18 +207,21 @@ def del_banque(request): @login_required def index_article(request): + is_trez = request.user.has_perms(('trésorier',)) article_list = Article.objects.order_by('name') - return render(request, 'cotisations/index_article.html', {'article_list':article_list}) + return render(request, 'cotisations/index_article.html', {'article_list':article_list, 'is_trez':is_trez}) @login_required def index_paiement(request): + is_trez = request.user.has_perms(('trésorier',)) paiement_list = Paiement.objects.order_by('moyen') - return render(request, 'cotisations/index_paiement.html', {'paiement_list':paiement_list}) + return render(request, 'cotisations/index_paiement.html', {'paiement_list':paiement_list, 'is_trez':is_trez}) @login_required def index_banque(request): + is_trez = request.user.has_perms(('trésorier',)) banque_list = Banque.objects.order_by('name') - return render(request, 'cotisations/index_banque.html', {'banque_list':banque_list}) + return render(request, 'cotisations/index_banque.html', {'banque_list':banque_list, 'is_trez':is_trez}) @login_required def index(request): diff --git a/topologie/templates/topologie/aff_port.html b/topologie/templates/topologie/aff_port.html index dd15f1cc..24e53f23 100644 --- a/topologie/templates/topologie/aff_port.html +++ b/topologie/templates/topologie/aff_port.html @@ -16,7 +16,7 @@ {{ port.machine_interface }} {{ port.related }} {{ port.details }} - Editer + {% if is_admin %} Editer{% endif %} {% endfor %} diff --git a/topologie/templates/topologie/index.html b/topologie/templates/topologie/index.html index c95f1491..03b8beda 100644 --- a/topologie/templates/topologie/index.html +++ b/topologie/templates/topologie/index.html @@ -4,6 +4,9 @@ {% block title %}Switchs{% endblock %} {% block content %} +{% if is_admin %} + Ajouter un switch +{% endif %} {% include "topologie/aff_switch.html" with switch_list=switch_list %}

diff --git a/topologie/templates/topologie/index_p.html b/topologie/templates/topologie/index_p.html index 28ee8b23..647e8e52 100644 --- a/topologie/templates/topologie/index_p.html +++ b/topologie/templates/topologie/index_p.html @@ -5,8 +5,10 @@ {% block content %}

Switch {{ nom_switch }}

+{% if is_admin %} Editer Ajouter un port +{% endif %} {% include "topologie/aff_port.html" with port_list=port_list %}

diff --git a/topologie/templates/topologie/sidebar.html b/topologie/templates/topologie/sidebar.html index aaffefeb..b74e53d3 100644 --- a/topologie/templates/topologie/sidebar.html +++ b/topologie/templates/topologie/sidebar.html @@ -2,5 +2,4 @@ {% block sidebar %}

Liste des switchs

-

Ajouter un switch

{% endblock %} diff --git a/topologie/views.py b/topologie/views.py index ca36b2fd..54323a45 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -9,18 +9,20 @@ from users.views import form @login_required def index(request): + is_admin = request.user.has_perms(('admin',)) switch_list = Switch.objects.order_by('building', 'number') - return render(request, 'topologie/index.html', {'switch_list': switch_list}) + return render(request, 'topologie/index.html', {'switch_list': switch_list, 'is_admin':is_admin}) @login_required def index_port(request, switch_id): + is_admin = request.user.has_perms(('admin',)) try: switch = Switch.objects.get(pk=switch_id) except Switch.DoesNotExist: messages.error(request, u"Switch inexistant") return redirect("/topologie/") port_list = Port.objects.filter(switch = switch).order_by('port') - return render(request, 'topologie/index_p.html', {'port_list':port_list, 'id_switch':switch_id, 'nom_switch':switch}) + return render(request, 'topologie/index_p.html', {'port_list':port_list, 'id_switch':switch_id, 'nom_switch':switch, 'is_admin':is_admin}) @login_required @permission_required('admin') diff --git a/users/models.py b/users/models.py index 7e766e5b..107ecaaf 100644 --- a/users/models.py +++ b/users/models.py @@ -140,6 +140,9 @@ class User(AbstractBaseUser): return False return True + def has_perm(self, perm, obj=None): + return True + def has_module_perms(self, app_label): # Simplest version again return True