From 6ad7605bfe8d72e94696396fd7b39089174979f8 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 11 Sep 2017 03:37:01 +0200 Subject: [PATCH] FIx temporaires pour l'autodetect --- freeradius_utils/auth.py | 4 ++-- users/models.py | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 1556102e..26da6cbe 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -284,11 +284,11 @@ def decide_vlan_and_register_macauth(switch_id, port_number, mac_address): elif not room_user.first().has_access(): return (sw_name, 'Machine inconnue et adhérent non cotisant', VLAN_NOK) else: - result, reason = user.autoregister_machine(mac_address) + result, reason = room_user.first().autoregister_machine(mac_address, ipv4.first()) if result: return (sw_name, 'Access Ok, Capture de la mac...', VLAN_OK) else: - return (sw_name, u'Erreur dans le register mac %s' % reason, VLAN_NOK) + return (sw_name, u'Erreur dans le register mac %s' % reason + unicode(mac_address), VLAN_NOK) elif not interface.first().is_active: return (sw_name, 'Machine non active / adherent non cotisant', VLAN_NOK) else: diff --git a/users/models.py b/users/models.py index bf9f579e..2b3d38d9 100644 --- a/users/models.py +++ b/users/models.py @@ -474,14 +474,12 @@ class User(AbstractBaseUser): machine_parent.clean() domain = Domain() domain.name = self.pseudo.replace('_','-').lower() + str(all_machines.count()) - with transaction.atomic(), reversion.create_revision(): - machine_parent.save() - interface_cible.machine = machine_parent - interface_cible.save() - domain.interface_parent = interface_cible - domain.clean() - domain.save() - reversion.set_comment("Autocapture radius") + machine_parent.save() + interface_cible.machine = machine_parent + interface_cible.save() + domain.interface_parent = interface_cible + domain.clean() + domain.save() except Exception as e: return False, e return True, "Ok"