8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-25 22:22:26 +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 bf3865deb1
commit aed021821a
2 changed files with 8 additions and 12 deletions

View file

@ -22,7 +22,7 @@ class InterfaceSerializer(serializers.ModelSerializer):
fields = ('ipv4', 'mac_address', 'dns')
class ExtensionNameField(serializers.RelatedField):
def to_reprsentation(self, value):
def to_representation(self, value):
return value.name
class TypeSerializer(serializers.ModelSerializer):
@ -32,13 +32,7 @@ class TypeSerializer(serializers.ModelSerializer):
model = IpType
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):
ipv4 = IpList_ExtensionField(read_only=True)
class Meta:
model = Interface
fields = ('ipv4', 'dns')

View file

@ -469,12 +469,14 @@ def interface_list(request):
@login_required
@permission_required('serveur')
def alias(request):
aliass = Alias.objects.all()
alias = []
for a in aliass:
if a.interface_parent.ipv4:
alias.append(a)
alias = Alias.objects.all()
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)
@csrf_exempt