mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 08:53:46 +00:00
Fonction qui permet de savoir si une machine a le droit à internet ou non
This commit is contained in:
parent
2cb9ccd0f8
commit
2bcf765c57
2 changed files with 7 additions and 4 deletions
|
@ -10,6 +10,7 @@ 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))
|
||||
|
@ -41,6 +42,11 @@ 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))
|
||||
|
|
|
@ -62,10 +62,7 @@ def is_whitelisted(user):
|
|||
|
||||
def has_access(user):
|
||||
""" Renvoie si un utilisateur a accès à internet"""
|
||||
if user.state == User.STATE_ACTIVE and not is_ban(user) and ( is_adherent(user) or is_whitelisted(user)):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return user.state == User.STATE_ACTIVE and not is_ban(user) and ( is_adherent(user) or is_whitelisted(user))
|
||||
|
||||
def form(ctx, template, request):
|
||||
c = ctx
|
||||
|
|
Loading…
Reference in a new issue