mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Pour mettre l'extension et bien se faire chier, plus kikimeter
This commit is contained in:
parent
bf3865deb1
commit
aed021821a
2 changed files with 8 additions and 12 deletions
|
@ -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')
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue