8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-27 01:13:46 +00:00

Change ns path

This commit is contained in:
Gabriel Detraz 2016-12-26 17:43:41 +01:00 committed by root
parent 3b8bfe2ec8
commit b22b6fc90c
8 changed files with 49 additions and 10 deletions

View file

@ -20,7 +20,7 @@ class MxAdmin(VersionAdmin):
list_display = ('zone', 'priority', 'name') list_display = ('zone', 'priority', 'name')
class NsAdmin(VersionAdmin): class NsAdmin(VersionAdmin):
list_display = ('zone', 'interface') list_display = ('zone', 'ns')
class IpListAdmin(VersionAdmin): class IpListAdmin(VersionAdmin):
list_display = ('ipv4','ip_type') list_display = ('ipv4','ip_type')

View file

@ -152,11 +152,11 @@ class DelMxForm(ModelForm):
class NsForm(ModelForm): class NsForm(ModelForm):
class Meta: class Meta:
model = Ns model = Ns
fields = ['zone', 'interface'] fields = ['zone', 'ns']
class DelNsForm(ModelForm): class DelNsForm(ModelForm):
ns = forms.ModelMultipleChoiceField(queryset=Ns.objects.all(), label="Enregistrements NS actuels", widget=forms.CheckboxSelectMultiple) ns = forms.ModelMultipleChoiceField(queryset=Ns.objects.all(), label="Enregistrements NS actuels", widget=forms.CheckboxSelectMultiple)
class Meta: class Meta:
exclude = ['zone', 'interface'] exclude = ['zone', 'ns']
model = Ns model = Ns

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('machines', '0040_remove_interface_dns'),
]
operations = [
migrations.RemoveField(
model_name='ns',
name='interface',
),
]

View file

@ -0,0 +1,21 @@
# -*- 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', '0041_remove_ns_interface'),
]
operations = [
migrations.AddField(
model_name='ns',
name='ns',
field=models.OneToOneField(to='machines.Domain', default=1, on_delete=django.db.models.deletion.PROTECT),
preserve_default=False,
),
]

View file

@ -64,10 +64,10 @@ class Ns(models.Model):
PRETTY_NAME = "Enregistrements NS" PRETTY_NAME = "Enregistrements NS"
zone = models.ForeignKey('Extension', on_delete=models.PROTECT) zone = models.ForeignKey('Extension', on_delete=models.PROTECT)
interface = models.OneToOneField('Interface', on_delete=models.PROTECT) ns = models.OneToOneField('Domain', on_delete=models.PROTECT)
def __str__(self): def __str__(self):
return str(self.zone) + ' ' + str(self.interface) return str(self.zone) + ' ' + str(self.ns)
class Interface(models.Model): class Interface(models.Model):
PRETTY_NAME = "Interface" PRETTY_NAME = "Interface"

View file

@ -67,17 +67,17 @@ class MxSerializer(serializers.ModelSerializer):
class NsSerializer(serializers.ModelSerializer): class NsSerializer(serializers.ModelSerializer):
zone = serializers.SerializerMethodField('get_zone_name') zone = serializers.SerializerMethodField('get_zone_name')
interface = serializers.SerializerMethodField('get_interface_name') ns = serializers.SerializerMethodField('get_interface_name')
class Meta: class Meta:
model = Ns model = Ns
fields = ('zone', 'interface') fields = ('zone', 'ns')
def get_zone_name(self, obj): def get_zone_name(self, obj):
return obj.zone.name return obj.zone.name
def get_interface_name(self, obj): def get_interface_name(self, obj):
return obj.interface return obj.ns
class DomainSerializer(serializers.ModelSerializer): class DomainSerializer(serializers.ModelSerializer):
extension = serializers.SerializerMethodField('get_zone_name') extension = serializers.SerializerMethodField('get_zone_name')

View file

@ -10,7 +10,7 @@
{% for ns in ns_list %} {% for ns in ns_list %}
<tr> <tr>
<td>{{ ns.zone }}</td> <td>{{ ns.zone }}</td>
<td>{{ ns.interface }}</td> <td>{{ ns.ns }}</td>
<td class="text-right"> <td class="text-right">
{% if is_infra %} {% if is_infra %}
{% include 'buttons/edit.html' with href='machines:edit-ns' id=ns.id %} {% include 'buttons/edit.html' with href='machines:edit-ns' id=ns.id %}

View file

@ -730,7 +730,7 @@ def mx(request):
@login_required @login_required
@permission_required('serveur') @permission_required('serveur')
def ns(request): def ns(request):
ns = Ns.objects.filter(interface__in=Interface.objects.exclude(ipv4=None)) ns = Ns.objects.exclude(ns__in=Domain.objects.filter(interface_parent__in=Interface.objects.filter(ipv4=None)))
seria = NsSerializer(ns, many=True) seria = NsSerializer(ns, many=True)
return JSONResponse(seria.data) return JSONResponse(seria.data)