From ee9b6e4c88457c96d7b749d99fbf4b2fec94e7fb Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 5 Jul 2016 12:39:31 +0200 Subject: [PATCH] =?UTF-8?q?Deplace=20la=20fonction=20precedemment=20cr?= =?UTF-8?q?=C3=A9e=20pour=20=C3=A9viter=20les=20imports=20circulaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/views.py | 6 ------ users/views.py | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/machines/views.py b/machines/views.py index 5844d16c..f06eb5ff 100644 --- a/machines/views.py +++ b/machines/views.py @@ -10,7 +10,6 @@ from django.contrib import messages from .models import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, NewInterfaceForm from .models import Machine, Interface, IpList from users.models import User -from users.views import has_access def unassign_ips(user): machines = Interface.objects.filter(machine=Machine.objects.filter(user=user)) @@ -42,11 +41,6 @@ def unassign_ipv4(interface): interface.ipv4 = None interface.save() -def is_active(interface): - machine = interface.machine - user = machine.user - return machine.active and has_access(user) - def form(ctx, template, request): c = ctx c.update(csrf(request)) diff --git a/users/views.py b/users/views.py index 2e00b1d7..c5d734cc 100644 --- a/users/views.py +++ b/users/views.py @@ -64,6 +64,12 @@ def has_access(user): """ Renvoie si un utilisateur a accès à internet""" return user.state == User.STATE_ACTIVE and not is_ban(user) and ( is_adherent(user) or is_whitelisted(user)) +def is_active(interface): + """ Renvoie si une interface doit avoir accès ou non """ + machine = interface.machine + user = machine.user + return machine.active and has_access(user) + def form(ctx, template, request): c = ctx c.update(csrf(request))