8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Cache les boutons si les acl ne sont pas suffisantes

This commit is contained in:
chirac 2016-07-09 14:17:05 +02:00
parent 8b04495166
commit ee324af6fa
13 changed files with 28 additions and 11 deletions

View file

@ -14,7 +14,7 @@
<td>{{ article.prix }}</td>
<td>{{ article.cotisation }}</td>
<td>{{ article.duration }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-article' article.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a></td>
<td>{% if is_trez %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-article' article.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
</tr>
{% endfor %}
</table>

View file

@ -8,7 +8,7 @@
{% for banque in banque_list %}
<tr>
<td>{{ banque.name }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-banque' banque.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a></td>
<td>{% if is_trez %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-banque' banque.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
</tr>
{% endfor %}
</table>

View file

@ -8,7 +8,7 @@
{% for paiement in paiement_list %}
<tr>
<td>{{ paiement.moyen }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-paiement' paiement.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a></td>
<td>{% if is_trez %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:edit-paiement' paiement.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
</tr>
{% endfor %}
</table>

View file

@ -5,8 +5,10 @@
{% block content %}
<h2>Liste des types d'articles</h2>
{% if is_trez %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-article' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type d'articles</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:del-article' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types d'articles</a>
{% endif %}
{% include "cotisations/aff_article.html" with article_list=article_list %}
<br />
<br />

View file

@ -6,7 +6,9 @@
{% block content %}
<h2>Liste des banques</h2>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-banque' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une banque</a>
{% if is_trez %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:del-banque' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer une ou plusieurs banques</a>
{% endif %}
{% include "cotisations/aff_banque.html" with banque_list=banque_list %}
<br />
<br />

View file

@ -5,8 +5,10 @@
{% block content %}
<h2>Liste des types de paiements</h2>
{% if is_trez %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:add-paiement' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type de paiement</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:del-paiement' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types de paiements</a>
{% endif %}
{% include "cotisations/aff_paiement.html" with paiement_list=paiement_list %}
<br />
<br />

View file

@ -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):

View file

@ -16,7 +16,7 @@
<td>{{ port.machine_interface }}</td>
<td>{{ port.related }}</td>
<td>{{ port.details }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-port' port.id %}"><i class="glyphicon glyphicon-random"></i> Editer</a></td>
<td>{% if is_admin %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-port' port.id %}"><i class="glyphicon glyphicon-random"></i> Editer</a>{% endif %}</td>
</tr>
{% endfor %}
</table>

View file

@ -4,6 +4,9 @@
{% block title %}Switchs{% endblock %}
{% block content %}
{% if is_admin %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un switch</a>
{% endif %}
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
<br />
<br />

View file

@ -5,8 +5,10 @@
{% block content %}
<h2>Switch {{ nom_switch }}</h2>
{% if is_admin %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-switch' id_switch %}"><i class="glyphicon glyphicon-edit"></i> Editer</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-port' id_switch %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un port</a>
{% endif %}
{% include "topologie/aff_port.html" with port_list=port_list %}
<br />
<br />

View file

@ -2,5 +2,4 @@
{% block sidebar %}
<p><a href="{% url "topologie:index" %}">Liste des switchs</a></p>
<p><a href="{% url "topologie:new-switch" %}">Ajouter un switch</a></p>
{% endblock %}

View file

@ -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')

View file

@ -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