From 1343c68324e5984ce4505f25419bccbd6586a4e3 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 18 Dec 2016 22:25:21 +0000 Subject: [PATCH] =?UTF-8?q?Code=20dupliqu=C3=A9,=20simplifie=20+=20django?= =?UTF-8?q?=201.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- re2o/context_processors.py | 2 +- users/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/re2o/context_processors.py b/re2o/context_processors.py index 87dc3a9c..73a1721f 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -4,7 +4,7 @@ from .settings import SITE_NAME def context_user(request): user = request.user if user.is_authenticated(): - interfaces = Interface.objects.filter(machine=Machine.objects.filter(user=user, active=True)) + interfaces = user.user_interfaces() else: interfaces = None is_cableur = user.has_perms(('cableur',)) diff --git a/users/models.py b/users/models.py index 01f7a34c..6bff8adf 100644 --- a/users/models.py +++ b/users/models.py @@ -231,7 +231,7 @@ class User(AbstractBaseUser): and not self.is_ban() and (self.is_adherent() or self.is_whitelisted()) def user_interfaces(self): - return Interface.objects.filter(machine__in=Machine.objects.filter(user=self)) + return Interface.objects.filter(machine__in=Machine.objects.filter(user=self, active=True)) def has_module_perms(self, app_label): # Simplest version again