Commit 19747540 authored by Maël Kervella's avatar Maël Kervella Committed by Maël Kervella

DNS Zone endpoint is now a viewset

parent e6884ab4
......@@ -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'}
}
......@@ -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())
]
......@@ -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
......
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