Commit 9b9f2121 authored by Maël Kervella's avatar Maël Kervella

Serialize le SOA dans le REST des extensions

parent aa5cedc3
......@@ -285,10 +285,10 @@ class SOA(models.Model):
' {expire};expire\n'
' {ttl};TTL'
).format(
refresh=self.refresh,
retry=self.retry,
expire=self.expire,
ttl=self.expire
refresh=str(self.refresh).ljust(12),
retry=str(self.retry).ljust(12),
expire=str(self.expire).ljust(12),
ttl=str(self.ttl).ljust(12)
)
@cached_property
......
......@@ -158,10 +158,11 @@ class ExtensionSerializer(serializers.ModelSerializer):
des foreign_key donc evalués en get_..."""
origin = serializers.SerializerMethodField('get_origin_ip')
zone_entry = serializers.SerializerMethodField('get_zone_name')
soa = serializers.SerializerMethodField('get_soa_data')
class Meta:
model = Extension
fields = ('name', 'origin', 'origin_v6', 'zone_entry')
fields = ('name', 'origin', 'origin_v6', 'zone_entry', 'soa')
def get_origin_ip(self, obj):
return obj.origin.ipv4
......@@ -169,6 +170,9 @@ class ExtensionSerializer(serializers.ModelSerializer):
def get_zone_name(self, obj):
return str(obj.dns_entry)
def get_soa_data(self, obj):
return { 'mail': obj.soa.dns_soa_mail, 'param': obj.soa.dns_soa_param }
class MxSerializer(serializers.ModelSerializer):
"""Serialisation d'un MX, evaluation du nom, de la zone
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment