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

Pour mettre l'extension et bien se faire chier, plus kikimeter

This commit is contained in:
Dalahro 2016-11-18 20:16:40 +01:00
parent 904ce61929
commit 671c3c8900
2 changed files with 8 additions and 12 deletions

View file

@ -22,7 +22,7 @@ class InterfaceSerializer(serializers.ModelSerializer):
fields = ('ipv4', 'mac_address', 'dns') fields = ('ipv4', 'mac_address', 'dns')
class ExtensionNameField(serializers.RelatedField): class ExtensionNameField(serializers.RelatedField):
def to_reprsentation(self, value): def to_representation(self, value):
return value.name return value.name
class TypeSerializer(serializers.ModelSerializer): class TypeSerializer(serializers.ModelSerializer):
@ -32,13 +32,7 @@ class TypeSerializer(serializers.ModelSerializer):
model = IpType model = IpType
fields = ('type', 'extension', 'domaine_ip', 'domaine_range') fields = ('type', 'extension', 'domaine_ip', 'domaine_range')
class IpList_ExtensionField(serializers.RelatedField):
def to_representation(self, value):
return value.ipv4.ip_type.extension.name
class InterfaceDNS_ExtensionSerializer(serializers.ModelSerializer): class InterfaceDNS_ExtensionSerializer(serializers.ModelSerializer):
ipv4 = IpList_ExtensionField(read_only=True)
class Meta: class Meta:
model = Interface model = Interface
fields = ('ipv4', 'dns') fields = ('ipv4', 'dns')

View file

@ -469,12 +469,14 @@ def interface_list(request):
@login_required @login_required
@permission_required('serveur') @permission_required('serveur')
def alias(request): def alias(request):
aliass = Alias.objects.all() alias = Alias.objects.all()
alias = []
for a in aliass:
if a.interface_parent.ipv4:
alias.append(a)
seria = AliasSerializer(alias, many=True) seria = AliasSerializer(alias, many=True)
for d in seria.data:
if d["interface_parent"]["ipv4"]:
id = d["interface_parent"]["ipv4"]
ip_list = IpList.objects.get(pk=id)
d["interface_parent"]["extension"] = ip_list.ip_type.extension.name
d["interface_parent"].pop("ipv4")
return JSONResponse(seria.data) return JSONResponse(seria.data)
@csrf_exempt @csrf_exempt