diff --git a/re2o/context_processors.py b/re2o/context_processors.py index d4de21b8..3cd99903 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -1,7 +1,12 @@ +from machines.models import Interface, Machine def context_user(request): 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_bureau = user.has_perms(('bureau',)) is_bofh = user.has_perms(('bofh',)) @@ -14,4 +19,5 @@ def context_user(request): 'is_bofh': is_bofh, 'is_trez': is_trez, 'is_infra': is_infra, + 'interfaces': interfaces, } diff --git a/templates/base.html b/templates/base.html index 7752431f..f734fd74 100644 --- a/templates/base.html +++ b/templates/base.html @@ -96,9 +96,15 @@

Vous n'êtes pas authentifié

{% endif %} + {% if request_user.is_authenticated %}
-

ADS

+ {{ interfaces|length }} machines actives + {% for interface in interfaces|slice:":5" %} +
  • {{interface.dns}}
  • + {% endfor %} +

    Voir toutes mes machines

    + {% endif %}