8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 22:52:26 +00:00

DNS Zone endpoint is now a viewset

This commit is contained in:
Maël Kervella 2018-06-10 00:50:57 +00:00 committed by Maël Kervella
parent e6884ab4da
commit 197475409c
3 changed files with 8 additions and 4 deletions

View file

@ -561,7 +561,7 @@ class CNAMERecordSerializer(serializers.ModelSerializer):
fields = ('alias', 'hostname')
class DNSZonesSerializer(serializers.ModelSerializer):
class DNSZonesSerializer(NamespacedHMSerializer):
soa = SOARecordSerializer()
ns_records = NSRecordSerializer(many=True, source='ns_set')
originv4 = OriginV4RecordSerializer(source='origin')
@ -577,4 +577,7 @@ class DNSZonesSerializer(serializers.ModelSerializer):
model = machines.Extension
fields = ('name', 'soa', 'ns_records', 'originv4', 'originv6',
'mx_records', 'txt_records', 'srv_records', 'a_records',
'aaaa_records', 'cname_records')
'aaaa_records', 'cname_records', 'api_url')
extra_kwargs = {
'api_url': {'view_name': 'dnszone-detail'}
}

View file

@ -86,11 +86,12 @@ router.register(r'users/listrights', views.ListRightViewSet)
router.register(r'users/shells', views.ShellViewSet, base_name='shell')
router.register(r'users/bans', views.BanViewSet)
router.register(r'users/whitelists', views.WhitelistViewSet)
# DNS
router.register(r'dns/zones', views.DNSZonesViewSet, base_name='dnszone')
urlpatterns = [
url(r'^', include(router.urls)),
url(r'^dhcp/hostmacip', views.HostMacIpView.as_view()),
url(r'^dns/zones', views.DNSZonesView.as_view()),
url(r'^services/regen', views.ServiceRegenView.as_view()),
url(r'^token-auth', views.ObtainExpiringAuthToken.as_view())
]

View file

@ -340,7 +340,7 @@ class HostMacIpView(generics.ListAPIView):
# DNS views
class DNSZonesView(generics.ListAPIView):
class DNSZonesViewSet(viewsets.ReadOnlyModelViewSet):
queryset = machines.Extension.objects.all()
serializer_class = serializers.DNSZonesSerializer