From 4dff4b0c02b901bea61c5072618cbf37f9a53860 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Sat, 1 Apr 2017 20:22:25 +0000 Subject: [PATCH] Move api lower --- stagestatus/apps/machines/api/routers.py | 7 ++++ .../apps/machines/{ => api}/serializers.py | 0 stagestatus/apps/machines/api/viewsets.py | 32 +++++++++++++++++++ stagestatus/apps/machines/routers.py | 6 ---- .../apps/machines/tests/test_serializers.py | 2 +- stagestatus/apps/machines/viewsets.py | 31 ------------------ 6 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 stagestatus/apps/machines/api/routers.py rename stagestatus/apps/machines/{ => api}/serializers.py (100%) create mode 100644 stagestatus/apps/machines/api/viewsets.py delete mode 100644 stagestatus/apps/machines/routers.py delete mode 100644 stagestatus/apps/machines/viewsets.py diff --git a/stagestatus/apps/machines/api/routers.py b/stagestatus/apps/machines/api/routers.py new file mode 100644 index 0000000..3593fdd --- /dev/null +++ b/stagestatus/apps/machines/api/routers.py @@ -0,0 +1,7 @@ +import machines.api.viewsets as vs +from rest_framework import routers +router = routers.SimpleRouter() + +router.register('machine', vs.MachineViewSet) +router.register('machine_note', vs.MachineNoteViewSet) +router.register('machine_status', vs.MachineStatusViewSet) diff --git a/stagestatus/apps/machines/serializers.py b/stagestatus/apps/machines/api/serializers.py similarity index 100% rename from stagestatus/apps/machines/serializers.py rename to stagestatus/apps/machines/api/serializers.py diff --git a/stagestatus/apps/machines/api/viewsets.py b/stagestatus/apps/machines/api/viewsets.py new file mode 100644 index 0000000..f62ff36 --- /dev/null +++ b/stagestatus/apps/machines/api/viewsets.py @@ -0,0 +1,32 @@ +from rest_framework import mixins +from rest_framework import viewsets + +from machines.api.serializers import ( + MachineSerializer, + MachineNoteSerializer, + MachineStatusSerializer +) + +from machines.api.models import ( + Machine, + MachineNote, + MachineStatus +) + + +class MachineViewSet(mixins.ListModelMixin, + viewsets.GenericViewSet): + serializer_class = MachineSerializer + queryset = Machine.objects.all() + + +class MachineNoteViewSet(mixins.ListModelMixin, + viewsets.GenericViewSet): + serializer_class = MachineNoteSerializer + queryset = MachineNote.objects.all() + + +class MachineStatusViewSet(mixins.ListModelMixin, + viewsets.GenericViewSet): + serializer_class = MachineStatusSerializer + queryset = MachineStatus.objects.all() diff --git a/stagestatus/apps/machines/routers.py b/stagestatus/apps/machines/routers.py deleted file mode 100644 index be21c86..0000000 --- a/stagestatus/apps/machines/routers.py +++ /dev/null @@ -1,6 +0,0 @@ -import machines.viewsets -from rest_framework import routers -router = routers.SimpleRouter() -router.register('machine', machines.viewsets.MachineViewSet) -router.register('machine_note', machines.viewsets.MachineNoteViewSet) -router.register('machine_status', machines.viewsets.MachineStatusViewSet) diff --git a/stagestatus/apps/machines/tests/test_serializers.py b/stagestatus/apps/machines/tests/test_serializers.py index cbe2d01..c13a58b 100644 --- a/stagestatus/apps/machines/tests/test_serializers.py +++ b/stagestatus/apps/machines/tests/test_serializers.py @@ -9,7 +9,7 @@ from rest_framework.renderers import JSONRenderer from django.contrib.auth.models import User from machines.models import Machine, MachineStatus, MachineNote -from machines.serializers import MachineSerializer +from machines.api.serializers import MachineSerializer class SerializerTest(TestCase): diff --git a/stagestatus/apps/machines/viewsets.py b/stagestatus/apps/machines/viewsets.py deleted file mode 100644 index 3639513..0000000 --- a/stagestatus/apps/machines/viewsets.py +++ /dev/null @@ -1,31 +0,0 @@ -from rest_framework import mixins -from rest_framework import viewsets -import machines.serializers -import machines.models - - -class MachineViewSet(mixins.UpdateModelMixin, - mixins.CreateModelMixin, - mixins.ListModelMixin, - viewsets.GenericViewSet): - - serializer_class = machines.serializers.MachineSerializer - queryset = machines.models.Machine.objects.all() - - -class MachineNoteViewSet(mixins.UpdateModelMixin, - mixins.CreateModelMixin, - mixins.ListModelMixin, - viewsets.GenericViewSet): - - serializer_class = machines.serializers.MachineNoteSerializer - queryset = machines.models.MachineNote.objects.all() - - -class MachineStatusViewSet(mixins.UpdateModelMixin, - mixins.CreateModelMixin, - mixins.ListModelMixin, - viewsets.GenericViewSet): - - serializer_class = machines.serializers.MachineStatusSerializer - queryset = machines.models.MachineStatus.objects.all()