diff --git a/re2o/settings.py b/re2o/settings.py index 521ed01d..f5ecccb1 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE, CSRF_COOKIE_HTTPONLY, X_FRAME_OPTIONS, SESSION_COOKIE_AGE, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, MAIN_EXTENSION, GID_RANGES, UID_RANGES, ASSO_PSEUDO, SEARCH_RESULT, MAX_INTERFACES, MAX_ALIAS +from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE, CSRF_COOKIE_HTTPONLY, X_FRAME_OPTIONS, SESSION_COOKIE_AGE, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP, MAIN_EXTENSION, GID_RANGES, UID_RANGES, ASSO_PSEUDO, SEARCH_RESULT, MAX_INTERFACES, MAX_ALIAS, VLAN_ID_LIST, RADIUS_VLAN_DECISION BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/topologie/admin.py b/topologie/admin.py index a3ffa335..3d5c8533 100644 --- a/topologie/admin.py +++ b/topologie/admin.py @@ -8,7 +8,7 @@ class SwitchAdmin(VersionAdmin): list_display = ('switch_interface','location','number','details') class PortAdmin(VersionAdmin): - list_display = ('switch', 'port','room','machine_interface','details') + list_display = ('switch', 'port','room','machine_interface','radius','details') class RoomAdmin(VersionAdmin): list_display = ('name','details') diff --git a/topologie/forms.py b/topologie/forms.py index 954ce47a..164c01ae 100644 --- a/topologie/forms.py +++ b/topologie/forms.py @@ -8,7 +8,7 @@ class PortForm(ModelForm): class EditPortForm(ModelForm): class Meta(PortForm.Meta): - fields = ['room', 'machine_interface', 'related', 'details'] + fields = ['room', 'machine_interface', 'related', 'radius', 'details'] def __init__(self, *args, **kwargs): super(EditPortForm, self).__init__(*args, **kwargs) @@ -16,7 +16,7 @@ class EditPortForm(ModelForm): class AddPortForm(ModelForm): class Meta(PortForm.Meta): - fields = ['port', 'room', 'machine_interface', 'related', 'details'] + fields = ['port', 'room', 'machine_interface', 'related', 'radius', 'details'] class EditSwitchForm(ModelForm): class Meta: diff --git a/topologie/migrations/0021_port_radius.py b/topologie/migrations/0021_port_radius.py new file mode 100644 index 00000000..58de03a0 --- /dev/null +++ b/topologie/migrations/0021_port_radius.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('topologie', '0020_auto_20161119_0033'), + ] + + operations = [ + migrations.AddField( + model_name='port', + name='radius', + field=models.CharField(choices=[('NO', 'NO'), ('STRICT', 'STRICT'), ('BLOQ', 'BLOQ'), ('COMMON', 'COMMON'), (7, 7), (8, 8), (42, 42), (69, 69)], max_length=32, default='NO'), + ), + ] diff --git a/topologie/models.py b/topologie/models.py index 9ceec033..a49c6825 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -5,6 +5,8 @@ from django.contrib.contenttypes.fields import GenericForeignKey from django.core.exceptions import ValidationError import reversion +from re2o.settings import VLAN_ID_LIST + def make_port_related(port): related_port = port.related related_port.related = port @@ -28,12 +30,20 @@ class Switch(models.Model): class Port(models.Model): PRETTY_NAME = "Port de switch" + STATES_BASE = ( + ('NO', 'NO'), + ('STRICT', 'STRICT'), + ('BLOQ', 'BLOQ'), + ('COMMON', 'COMMON'), + ) + STATES = STATES_BASE + tuple([(id, id) for id in VLAN_ID_LIST]) switch = models.ForeignKey('Switch', related_name="ports") port = models.IntegerField() room = models.ForeignKey('Room', on_delete=models.PROTECT, blank=True, null=True) machine_interface = models.ForeignKey('machines.Interface', on_delete=models.SET_NULL, blank=True, null=True) related = models.OneToOneField('self', null=True, blank=True, related_name='related_port') + radius = models.CharField(max_length=32, choices=STATES, default='NO') 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 cfd59374..6f64c456 100644 --- a/topologie/templates/topologie/aff_port.html +++ b/topologie/templates/topologie/aff_port.html @@ -5,6 +5,7 @@ Room Interface machine Related + Radius Détails @@ -27,6 +28,7 @@ {{ port.related }} {% endif %} + {{ port.radius }} {{ port.details }}