From 62d51397848e120999bc8a5508cda666fbadaae2 Mon Sep 17 00:00:00 2001 From: histausse Date: Tue, 1 Sep 2020 17:20:37 +0200 Subject: [PATCH] Add building to the room serialiser Add dormitory to the building serialiser Add dormitory to the building serialiser Add dormitory to the building serialiser Add dormitory to the building serialiser Add building to the room serialiser Add dormitory to the building serialiser Add dormitory to the building serialiser Add dormitory to the building serialiser Add dormitory to the building serialiser --- topologie/api/serializers.py | 2 +- topologie/api/urls.py | 1 + topologie/api/views.py | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/topologie/api/serializers.py b/topologie/api/serializers.py index 2e3a6c0f..ce03a842 100644 --- a/topologie/api/serializers.py +++ b/topologie/api/serializers.py @@ -117,7 +117,7 @@ class BuildingSerializer(NamespacedHMSerializer): model = topologie.Building fields = ("name", "dormitory", "api_url") -class DormitorySerializer(NamespaceHMSerializer): +class DormitorySerializer(NamespacedHMSerializer): """Serialize `topologie.models.Dormitory` objects """ class Meta: diff --git a/topologie/api/urls.py b/topologie/api/urls.py index f6febb95..1cfd2d3e 100644 --- a/topologie/api/urls.py +++ b/topologie/api/urls.py @@ -30,6 +30,7 @@ urls_viewset = [ (r"topologie/constructorswitch", views.ConstructorSwitchViewSet, None), (r"topologie/switchbay", views.SwitchBayViewSet, None), (r"topologie/building", views.BuildingViewSet, None), + (r"topologie/dormitory", views.DormitoryViewSet, None), (r"topologie/switchport", views.SwitchPortViewSet, "switchport"), (r"topologie/portprofile", views.PortProfileViewSet, "portprofile"), (r"topologie/room", views.RoomViewSet, None) diff --git a/topologie/api/views.py b/topologie/api/views.py index 5e937cda..8c504499 100644 --- a/topologie/api/views.py +++ b/topologie/api/views.py @@ -114,6 +114,13 @@ class RoomViewSet(viewsets.ReadOnlyModelViewSet): queryset = topologie.Room.objects.all() serializer_class = serializers.RoomSerializer +class DormitoryViewSet(viewsets.ReadOnlyModelViewSet): + """Exposes list and details of `topologie.models.Dormitory` + objects. + """ + + queryset = topologie.Room.objects.all() + serializer_class = serializers.DormitorySerializer class PortProfileViewSet(viewsets.ReadOnlyModelViewSet): """Exposes list and details of `topologie.models.PortProfile` objects. @@ -146,4 +153,4 @@ class RoleView(generics.ListAPIView): """ queryset = machines.Role.objects.all().prefetch_related("servers") - serializer_class = serializers.RoleSerializer \ No newline at end of file + serializer_class = serializers.RoleSerializer