mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
Deplace la fonction precedemment crée pour éviter les imports circulaires
This commit is contained in:
parent
cc6f98f92f
commit
ee9b6e4c88
2 changed files with 6 additions and 6 deletions
|
@ -10,7 +10,6 @@ from django.contrib import messages
|
||||||
from .models import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, NewInterfaceForm
|
from .models import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, NewInterfaceForm
|
||||||
from .models import Machine, Interface, IpList
|
from .models import Machine, Interface, IpList
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from users.views import has_access
|
|
||||||
|
|
||||||
def unassign_ips(user):
|
def unassign_ips(user):
|
||||||
machines = Interface.objects.filter(machine=Machine.objects.filter(user=user))
|
machines = Interface.objects.filter(machine=Machine.objects.filter(user=user))
|
||||||
|
@ -42,11 +41,6 @@ def unassign_ipv4(interface):
|
||||||
interface.ipv4 = None
|
interface.ipv4 = None
|
||||||
interface.save()
|
interface.save()
|
||||||
|
|
||||||
def is_active(interface):
|
|
||||||
machine = interface.machine
|
|
||||||
user = machine.user
|
|
||||||
return machine.active and has_access(user)
|
|
||||||
|
|
||||||
def form(ctx, template, request):
|
def form(ctx, template, request):
|
||||||
c = ctx
|
c = ctx
|
||||||
c.update(csrf(request))
|
c.update(csrf(request))
|
||||||
|
|
|
@ -64,6 +64,12 @@ def has_access(user):
|
||||||
""" Renvoie si un utilisateur a accès à internet"""
|
""" 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))
|
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):
|
def form(ctx, template, request):
|
||||||
c = ctx
|
c = ctx
|
||||||
c.update(csrf(request))
|
c.update(csrf(request))
|
||||||
|
|
Loading…
Reference in a new issue