8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Serialize le SOA dans le REST des extensions

This commit is contained in:
Maël Kervella 2017-10-20 00:28:47 +00:00
parent aa5cedc37a
commit 9b9f2121c1
2 changed files with 9 additions and 5 deletions

View file

@ -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

View file

@ -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