mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
Export des ipv6 en rest
This commit is contained in:
parent
abbceb6abc
commit
7171891c02
2 changed files with 29 additions and 2 deletions
|
@ -55,6 +55,25 @@ class InterfaceSerializer(serializers.ModelSerializer):
|
||||||
def get_macaddress(self, obj):
|
def get_macaddress(self, obj):
|
||||||
return str(obj.mac_address)
|
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):
|
class ExtensionNameField(serializers.RelatedField):
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
return value.name
|
return value.name
|
||||||
|
|
|
@ -41,7 +41,7 @@ from django.contrib.auth import authenticate, login
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
from rest_framework.renderers import JSONRenderer
|
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 import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
|
||||||
|
@ -1027,6 +1027,14 @@ def mac_ip_list(request):
|
||||||
seria = InterfaceSerializer(interfaces, many=True)
|
seria = InterfaceSerializer(interfaces, many=True)
|
||||||
return seria.data
|
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
|
@csrf_exempt
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('serveur')
|
@permission_required('serveur')
|
||||||
|
@ -1086,7 +1094,7 @@ def mac_ip(request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('serveur')
|
@permission_required('serveur')
|
||||||
def mac_ip_dns(request):
|
def mac_ip_dns(request):
|
||||||
seria = mac_ip_list(request)
|
seria = full_mac_ip_list(request)
|
||||||
return JSONResponse(seria)
|
return JSONResponse(seria)
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
|
Loading…
Reference in a new issue