diff --git a/machines/forms.py b/machines/forms.py
index 8ea1b469..6a8d8d27 100644
--- a/machines/forms.py
+++ b/machines/forms.py
@@ -64,6 +64,12 @@ class AliasForm(ModelForm):
model = Alias
fields = ['alias','extension']
+ def __init__(self, *args, **kwargs):
+ infra = kwargs.pop('infra')
+ super(AliasForm, self).__init__(*args, **kwargs)
+ if not infra:
+ self.fields['extension'].queryset = Extension.objects.filter(need_infra=False)
+
class DelAliasForm(ModelForm):
alias = forms.ModelMultipleChoiceField(queryset=Alias.objects.all(), label="Alias actuels", widget=forms.CheckboxSelectMultiple)
@@ -113,7 +119,7 @@ class DelIpTypeForm(ModelForm):
class ExtensionForm(ModelForm):
class Meta:
model = Extension
- fields = ['name', 'origin']
+ fields = ['name', 'need_infra', 'origin']
def __init__(self, *args, **kwargs):
super(ExtensionForm, self).__init__(*args, **kwargs)
@@ -124,7 +130,7 @@ class DelExtensionForm(ModelForm):
extensions = forms.ModelMultipleChoiceField(queryset=Extension.objects.all(), label="Extensions actuelles", widget=forms.CheckboxSelectMultiple)
class Meta:
- exclude = ['name', 'origin']
+ exclude = ['name', 'need_infra', 'origin']
model = Extension
class MxForm(ModelForm):
diff --git a/machines/migrations/0033_extension_need_infra.py b/machines/migrations/0033_extension_need_infra.py
new file mode 100644
index 00000000..f603240c
--- /dev/null
+++ b/machines/migrations/0033_extension_need_infra.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('machines', '0032_auto_20161119_1850'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='extension',
+ name='need_infra',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/machines/models.py b/machines/models.py
index e094460c..764247ab 100644
--- a/machines/models.py
+++ b/machines/models.py
@@ -44,6 +44,7 @@ class Extension(models.Model):
PRETTY_NAME = "Extensions dns"
name = models.CharField(max_length=255, unique=True)
+ need_infra = models.BooleanField(default=False)
origin = models.OneToOneField('IpList', on_delete=models.PROTECT, blank=True, null=True)
def __str__(self):
diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html
index 5753bf8d..68c03026 100644
--- a/machines/templates/machines/aff_extension.html
+++ b/machines/templates/machines/aff_extension.html
@@ -2,14 +2,16 @@
{% for extension in extension_list %}
Extension
- Enregistrement A origin
+ Autorisation infra pour utiliser l'extension
+ Enregistrement A origin