From ab1b4a16461eaf1d6253d1b7eed4101749ba2264 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 19 Nov 2016 18:52:59 +0100 Subject: [PATCH] =?UTF-8?q?G=C3=A8re=20l'enregistrement=20origin=20A=20sur?= =?UTF-8?q?=20une=20zone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/admin.py | 2 +- machines/forms.py | 5 ++-- .../migrations/0032_auto_20161119_1850.py | 25 +++++++++++++++++++ machines/models.py | 3 ++- .../templates/machines/aff_extension.html | 6 +++-- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 machines/migrations/0032_auto_20161119_1850.py diff --git a/machines/admin.py b/machines/admin.py index b2550c68..aa7d6bc5 100644 --- a/machines/admin.py +++ b/machines/admin.py @@ -14,7 +14,7 @@ class MachineTypeAdmin(VersionAdmin): class ExtensionAdmin(VersionAdmin): - list_display = ('name',) + list_display = ('name','origin') class MxAdmin(VersionAdmin): list_display = ('zone', 'priority', 'name') diff --git a/machines/forms.py b/machines/forms.py index d54427e1..0b2ceb87 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -112,17 +112,18 @@ class DelIpTypeForm(ModelForm): class ExtensionForm(ModelForm): class Meta: model = Extension - fields = ['name'] + fields = ['name', 'origin'] def __init__(self, *args, **kwargs): super(ExtensionForm, self).__init__(*args, **kwargs) self.fields['name'].label = 'Extension à ajouter' + self.fields['origin'].label = 'Enregistrement A origin' class DelExtensionForm(ModelForm): extensions = forms.ModelMultipleChoiceField(queryset=Extension.objects.all(), label="Extensions actuelles", widget=forms.CheckboxSelectMultiple) class Meta: - exclude = ['name'] + exclude = ['name', 'origin'] model = Extension class MxForm(ModelForm): diff --git a/machines/migrations/0032_auto_20161119_1850.py b/machines/migrations/0032_auto_20161119_1850.py new file mode 100644 index 00000000..f5b643c6 --- /dev/null +++ b/machines/migrations/0032_auto_20161119_1850.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0031_auto_20161119_1709'), + ] + + operations = [ + migrations.AddField( + model_name='extension', + name='origin', + field=models.OneToOneField(null=True, to='machines.IpList', blank=True, on_delete=django.db.models.deletion.PROTECT), + ), + migrations.AlterField( + model_name='extension', + name='name', + field=models.CharField(max_length=255, unique=True), + ), + ] diff --git a/machines/models.py b/machines/models.py index 0ff636c2..2602c86d 100644 --- a/machines/models.py +++ b/machines/models.py @@ -43,7 +43,8 @@ class IpType(models.Model): class Extension(models.Model): PRETTY_NAME = "Extensions dns" - name = models.CharField(max_length=255) + name = models.CharField(max_length=255, unique=True) + origin = models.OneToOneField('IpList', on_delete=models.PROTECT, blank=True, null=True) def __str__(self): return self.name diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html index 1ae5ef8c..5753bf8d 100644 --- a/machines/templates/machines/aff_extension.html +++ b/machines/templates/machines/aff_extension.html @@ -2,13 +2,15 @@ Extension - + Enregistrement A origin + {% for extension in extension_list %} {{ extension.name }} - + {{ extension.origin }} + {% if is_infra %} {% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %} {% endif %}