8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 03:43:12 +00:00

Résumé des machines

This commit is contained in:
Gabriel Detraz 2016-07-10 18:29:40 +02:00
parent e4598785ff
commit 9465ea5d21
2 changed files with 13 additions and 1 deletions

View file

@ -1,7 +1,12 @@
from machines.models import Interface, Machine
def context_user(request): def context_user(request):
user = request.user user = request.user
if user.is_authenticated():
interfaces = Interface.objects.filter(machine=Machine.objects.filter(user=user, active=True))
else:
interfaces = None
is_cableur = user.has_perms(('cableur',)) is_cableur = user.has_perms(('cableur',))
is_bureau = user.has_perms(('bureau',)) is_bureau = user.has_perms(('bureau',))
is_bofh = user.has_perms(('bofh',)) is_bofh = user.has_perms(('bofh',))
@ -14,4 +19,5 @@ def context_user(request):
'is_bofh': is_bofh, 'is_bofh': is_bofh,
'is_trez': is_trez, 'is_trez': is_trez,
'is_infra': is_infra, 'is_infra': is_infra,
'interfaces': interfaces,
} }

View file

@ -96,9 +96,15 @@
<p>Vous n'êtes pas authentifié</p> <p>Vous n'êtes pas authentifié</p>
{% endif %} {% endif %}
</div> </div>
{% if request_user.is_authenticated %}
<div class="well"> <div class="well">
<p>ADS</p> {{ interfaces|length }} machines actives
{% for interface in interfaces|slice:":5" %}
<li>{{interface.dns}}</li>
{% endfor %}
<p><a href="{% url "users:mon-profil" %}">Voir toutes mes machines</a></p>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>