diff --git a/machines/forms.py b/machines/forms.py index 863a4d6f..34d9652f 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -52,14 +52,14 @@ class BaseEditMachineForm(EditMachineForm): class EditInterfaceForm(ModelForm): class Meta: model = Interface - fields = '__all__' + # fields = '__all__' + exclude = ['port_lists'] def __init__(self, *args, **kwargs): super(EditInterfaceForm, self).__init__(*args, **kwargs) self.fields['mac_address'].label = 'Adresse mac' self.fields['type'].label = 'Type de machine' self.fields['type'].empty_label = "Séléctionner un type de machine" - self.fields['port_lists'].label = "Configuration des ports" if "machine" in self.fields: self.fields['machine'].queryset = Machine.objects.all().select_related('user') @@ -232,10 +232,10 @@ class VlanForm(ModelForm): class DelVlanForm(Form): vlan = forms.ModelMultipleChoiceField(queryset=Vlan.objects.all(), label="Vlan actuels", widget=forms.CheckboxSelectMultiple) -class EditPortForm(ModelForm): +class EditPortConfigForm(ModelForm): class Meta: - model = Port - fields = '__all__' + model = Interface + fields = ['port_lists'] class EditPortListForm(ModelForm): class Meta: diff --git a/machines/migrations/0061_auto_20171001_1727.py b/machines/migrations/0061_auto_20171001_1727.py new file mode 100644 index 00000000..661f9fd3 --- /dev/null +++ b/machines/migrations/0061_auto_20171001_1727.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-10-01 15:27 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0060_port_io'), + ] + + operations = [ + migrations.RemoveField( + model_name='portlist', + name='interfaces', + ), + migrations.AddField( + model_name='interface', + name='port_lists', + field=models.ManyToManyField(to='machines.PortList'), + ), + ] diff --git a/machines/models.py b/machines/models.py index 7c13e8eb..bf5a774d 100644 --- a/machines/models.py +++ b/machines/models.py @@ -279,6 +279,9 @@ class Interface(models.Model): domain = None return str(domain) + def has_private_ip(self): + return IPAddress(str(self.ipv4)).is_private() + class Domain(models.Model): PRETTY_NAME = "Domaine dns" diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index a09d8868..c4a2dd56 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -91,6 +91,11 @@ with this program; if not, write to the Free Software Foundation, Inc., Gerer les alias +