Commit 36044915 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by Simon Brélivet

Vue pour les zones, contenant les enregistrement origin

parent cbef3b29
......@@ -32,6 +32,16 @@ class TypeSerializer(serializers.ModelSerializer):
model = IpType
fields = ('type', 'extension', 'domaine_ip', 'domaine_range')
class ExtensionSerializer(serializers.ModelSerializer):
origin = serializers.SerializerMethodField('get_origin_ip')
class Meta:
model = Extension
fields = ('name', 'origin')
def get_origin_ip(self, obj):
return obj.origin.ipv4
class MxSerializer(serializers.ModelSerializer):
name = serializers.SerializerMethodField('get_alias_name')
zone = serializers.SerializerMethodField('get_zone_name')
......
......@@ -46,4 +46,5 @@ urlpatterns = [
url(r'^rest/corresp/$', views.corresp, name='corresp'),
url(r'^rest/mx/$', views.mx, name='mx'),
url(r'^rest/ns/$', views.ns, name='ns'),
url(r'^rest/zones/$', views.zones, name='zones'),
]
......@@ -16,7 +16,7 @@ from django.contrib.auth import authenticate, login
from django.views.decorators.csrf import csrf_exempt
from rest_framework.renderers import JSONRenderer
from machines.serializers import InterfaceSerializer, TypeSerializer, AliasSerializer, MxSerializer, NsSerializer
from machines.serializers import InterfaceSerializer, TypeSerializer, AliasSerializer, MxSerializer, ExtensionSerializer, NsSerializer
from reversion import revisions as reversion
......@@ -695,6 +695,14 @@ def ns(request):
seria = NsSerializer(ns, many=True)
return JSONResponse(seria.data)
@csrf_exempt
@login_required
@permission_required('serveur')
def zones(request):
zones = Extension.objects.all()
seria = ExtensionSerializer(zones, many=True)
return JSONResponse(seria.data)
@csrf_exempt
@login_required
@permission_required('serveur')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment