diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 4e9ad24e..b318ab63 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -369,15 +369,15 @@ def decide_vlan_and_register_switch(nas_machine, nas_type, port_number, else: DECISION_VLAN = VLAN_OK + if not port.state: + return (sw_name, port.room, u'Port desactive', VLAN_NOK) + if port_profil.radius_type == 'NO': return (sw_name, "", u"Pas d'authentification sur ce port" + extra_log, DECISION_VLAN) - if port_profil.radius_type == 'BLOQ': - return (sw_name, port.room, u'Port desactive', VLAN_NOK) - if port_profil.radius_type == 'STRICT': room = port.room if not room: diff --git a/topologie/forms.py b/topologie/forms.py index 6e4d5a0d..63ffc652 100644 --- a/topologie/forms.py +++ b/topologie/forms.py @@ -81,7 +81,7 @@ class EditPortForm(FormRevMixin, ModelForm): lent sans)""" class Meta(PortForm.Meta): fields = ['room', 'related', 'machine_interface', 'custom_profil', - 'details'] + 'state', 'details'] def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) @@ -110,6 +110,7 @@ class AddPortForm(FormRevMixin, ModelForm): 'machine_interface', 'related', 'custom_profil', + 'state', 'details' ] diff --git a/topologie/migrations/0066_auto_20180630_1855.py b/topologie/migrations/0066_auto_20180630_1855.py new file mode 100644 index 00000000..b197f568 --- /dev/null +++ b/topologie/migrations/0066_auto_20180630_1855.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-06-30 16:55 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('topologie', '0065_auto_20180630_1703'), + ] + + operations = [ + migrations.AddField( + model_name='port', + name='state', + field=models.BooleanField(default=True, help_text='Etat du port Actif', verbose_name='Etat du port Actif'), + ), + migrations.AlterField( + model_name='portprofile', + name='profil_default', + field=models.CharField(blank=True, choices=[('room', 'room'), ('accespoint', 'accesspoint'), ('uplink', 'uplink'), ('asso_machine', 'asso_machine'), ('nothing', 'nothing')], max_length=32, null=True, unique=True, verbose_name='profil default'), + ), + ] diff --git a/topologie/models.py b/topologie/models.py index 3d30af76..d0534dda 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -397,7 +397,11 @@ class Port(AclMixin, RevMixin, models.Model): blank=True, null=True ) - + state = models.BooleanField( + default=True, + help_text='Etat du port Actif', + verbose_name=_("Etat du port Actif") + ) details = models.CharField(max_length=255, blank=True) class Meta: diff --git a/topologie/templates/topologie/aff_port.html b/topologie/templates/topologie/aff_port.html index f878365a..45e81e06 100644 --- a/topologie/templates/topologie/aff_port.html +++ b/topologie/templates/topologie/aff_port.html @@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,