From 6099d6014724c2193a5b85f7f710cb468ca142b9 Mon Sep 17 00:00:00 2001 From: chirac Date: Sun, 10 Jul 2016 18:29:40 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9sum=C3=A9=20des=20machines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- re2o/context_processors.py | 6 ++++++ templates/base.html | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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 %}