mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 16:33:47 +00:00
Export des ipv6 en rest
This commit is contained in:
parent
4269ed74bc
commit
678056875a
2 changed files with 29 additions and 2 deletions
|
@ -55,6 +55,25 @@ class InterfaceSerializer(serializers.ModelSerializer):
|
|||
def get_macaddress(self, obj):
|
||||
return str(obj.mac_address)
|
||||
|
||||
class FullInterfaceSerializer(serializers.ModelSerializer):
|
||||
ipv4 = IpListSerializer(read_only=True)
|
||||
mac_address = serializers.SerializerMethodField('get_macaddress')
|
||||
domain = serializers.SerializerMethodField('get_dns')
|
||||
extension = serializers.SerializerMethodField('get_interface_extension')
|
||||
|
||||
class Meta:
|
||||
model = Interface
|
||||
fields = ('ipv4', 'ipv6', 'mac_address', 'domain', 'extension')
|
||||
|
||||
def get_dns(self, obj):
|
||||
return obj.domain.name
|
||||
|
||||
def get_interface_extension(self, obj):
|
||||
return obj.domain.extension.name
|
||||
|
||||
def get_macaddress(self, obj):
|
||||
return str(obj.mac_address)
|
||||
|
||||
class ExtensionNameField(serializers.RelatedField):
|
||||
def to_representation(self, value):
|
||||
return value.name
|
||||
|
|
|
@ -41,7 +41,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, DomainSerializer, TextSerializer, MxSerializer, ExtensionSerializer, ServiceServersSerializer, NsSerializer
|
||||
from machines.serializers import FullInterfaceSerializer, InterfaceSerializer, TypeSerializer, DomainSerializer, TextSerializer, MxSerializer, ExtensionSerializer, ServiceServersSerializer, NsSerializer
|
||||
from reversion import revisions as reversion
|
||||
from reversion.models import Version
|
||||
|
||||
|
@ -1027,6 +1027,14 @@ def mac_ip_list(request):
|
|||
seria = InterfaceSerializer(interfaces, many=True)
|
||||
return seria.data
|
||||
|
||||
@csrf_exempt
|
||||
@login_required
|
||||
@permission_required('serveur')
|
||||
def full_mac_ip_list(request):
|
||||
interfaces = all_active_assigned_interfaces()
|
||||
seria = FullInterfaceSerializer(interfaces, many=True)
|
||||
return seria.data
|
||||
|
||||
@csrf_exempt
|
||||
@login_required
|
||||
@permission_required('serveur')
|
||||
|
@ -1086,7 +1094,7 @@ def mac_ip(request):
|
|||
@login_required
|
||||
@permission_required('serveur')
|
||||
def mac_ip_dns(request):
|
||||
seria = mac_ip_list(request)
|
||||
seria = full_mac_ip_list(request)
|
||||
return JSONResponse(seria)
|
||||
|
||||
@csrf_exempt
|
||||
|
|
Loading…
Reference in a new issue