mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Crée une methode mac_bare, pour renvoyer les macs dans le bon format ldap
This commit is contained in:
parent
c944fbb917
commit
fa35818409
2 changed files with 5 additions and 2 deletions
|
@ -3,7 +3,7 @@ from django.db.models.signals import post_save, post_delete
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.forms import ValidationError
|
from django.forms import ValidationError
|
||||||
from macaddress.fields import MACAddressField
|
from macaddress.fields import MACAddressField
|
||||||
from netaddr import EUI
|
from netaddr import mac_bare, EUI
|
||||||
from django.core.validators import MinValueValidator,MaxValueValidator
|
from django.core.validators import MinValueValidator,MaxValueValidator
|
||||||
|
|
||||||
from re2o.settings import MAIN_EXTENSION
|
from re2o.settings import MAIN_EXTENSION
|
||||||
|
@ -86,6 +86,9 @@ class Interface(models.Model):
|
||||||
user = self.machine.user
|
user = self.machine.user
|
||||||
return machine.active and user.has_access()
|
return machine.active and user.has_access()
|
||||||
|
|
||||||
|
def mac_bare(self):
|
||||||
|
return str(EUI(self.mac_address, dialect=mac_bare)).lower()
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
self.mac_address = str(EUI(self.mac_address)) or None
|
self.mac_address = str(EUI(self.mac_address)) or None
|
||||||
if self.ipv4:
|
if self.ipv4:
|
||||||
|
|
|
@ -264,7 +264,7 @@ class User(AbstractBaseUser):
|
||||||
if access_refresh:
|
if access_refresh:
|
||||||
user_ldap.dialupAccess = str(self.has_access())
|
user_ldap.dialupAccess = str(self.has_access())
|
||||||
if mac_refresh:
|
if mac_refresh:
|
||||||
user_ldap.macs = [inter.mac_address for inter in Interface.objects.filter(machine=Machine.objects.filter(user=self))]
|
user_ldap.macs = [inter.mac_bare() for inter in Interface.objects.filter(machine=Machine.objects.filter(user=self))]
|
||||||
user_ldap.save()
|
user_ldap.save()
|
||||||
|
|
||||||
def ldap_del(self):
|
def ldap_del(self):
|
||||||
|
|
Loading…
Reference in a new issue