8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-12 21:06:27 +00:00

Stretch fix

This commit is contained in:
Gabriel Detraz 2016-12-26 23:48:32 +00:00 committed by root
parent 0c7c48f0fb
commit ad853470c0
2 changed files with 12 additions and 13 deletions

View file

@ -17,9 +17,8 @@ class IpListSerializer(serializers.ModelSerializer):
class InterfaceSerializer(serializers.ModelSerializer): class InterfaceSerializer(serializers.ModelSerializer):
ipv4 = IpListSerializer(read_only=True) ipv4 = IpListSerializer(read_only=True)
mac_address = serializers.SerializerMethodField('get_macaddress') mac_address = serializers.SerializerMethodField('get_macaddress')
dns = serializers.SerializerMethodField('get_dns')
domain = serializers.SerializerMethodField('get_dns') domain = serializers.SerializerMethodField('get_dns')
extension = serializers.SerializerMethodField('get_extension') extension = serializers.SerializerMethodField('get_interface_extension')
class Meta: class Meta:
model = Interface model = Interface
@ -28,7 +27,7 @@ class InterfaceSerializer(serializers.ModelSerializer):
def get_dns(self, obj): def get_dns(self, obj):
return obj.domain.name return obj.domain.name
def get_extension(self, obj): def get_interface_extension(self, obj):
return obj.domain.extension.name return obj.domain.extension.name
def get_macaddress(self, obj): def get_macaddress(self, obj):
@ -56,22 +55,22 @@ class ExtensionSerializer(serializers.ModelSerializer):
return obj.origin.ipv4 return obj.origin.ipv4
class MxSerializer(serializers.ModelSerializer): class MxSerializer(serializers.ModelSerializer):
name = serializers.SerializerMethodField('get_name') name = serializers.SerializerMethodField('get_mx_name')
zone = serializers.SerializerMethodField('get_zone_name') zone = serializers.SerializerMethodField('get_zone_name')
class Meta: class Meta:
model = Mx model = Mx
fields = ('zone', 'priority', 'name') fields = ('zone', 'priority', 'name')
def get_name(self, obj): def get_mx_name(self, obj):
return obj.name return str(obj.name)
def get_zone_name(self, obj): def get_zone_name(self, obj):
return obj.zone.name return obj.zone.name
class NsSerializer(serializers.ModelSerializer): class NsSerializer(serializers.ModelSerializer):
zone = serializers.SerializerMethodField('get_zone_name') zone = serializers.SerializerMethodField('get_zone_name')
ns = serializers.SerializerMethodField('get_interface_name') ns = serializers.SerializerMethodField('get_domain_name')
class Meta: class Meta:
model = Ns model = Ns
@ -80,12 +79,12 @@ class NsSerializer(serializers.ModelSerializer):
def get_zone_name(self, obj): def get_zone_name(self, obj):
return obj.zone.name return obj.zone.name
def get_interface_name(self, obj): def get_domain_name(self, obj):
return obj.ns return str(obj.ns)
class DomainSerializer(serializers.ModelSerializer): class DomainSerializer(serializers.ModelSerializer):
extension = serializers.SerializerMethodField('get_zone_name') extension = serializers.SerializerMethodField('get_zone_name')
cname = serializers.SerializerMethodField('get_cname') cname = serializers.SerializerMethodField('get_cname_name')
class Meta: class Meta:
model = Domain model = Domain
@ -94,6 +93,6 @@ class DomainSerializer(serializers.ModelSerializer):
def get_zone_name(self, obj): def get_zone_name(self, obj):
return obj.extension.name return obj.extension.name
def get_cname(self, obj): def get_cname_name(self, obj):
return obj.cname return str(obj.cname)

View file

@ -706,7 +706,7 @@ def interface_list(request):
@login_required @login_required
@permission_required('serveur') @permission_required('serveur')
def alias(request): def alias(request):
alias = Domain.objects.filter(interface_parent=None).filter(cname=Domain.objects.filter(interface_parent__in=Interface.objects.exclude(ipv4=None))) alias = Domain.objects.filter(interface_parent=None).filter(cname__in=Domain.objects.filter(interface_parent__in=Interface.objects.exclude(ipv4=None)))
seria = DomainSerializer(alias, many=True) seria = DomainSerializer(alias, many=True)
return JSONResponse(seria.data) return JSONResponse(seria.data)