Move api lower

This commit is contained in:
Tyrel Souza 2017-04-01 20:22:25 +00:00
parent 4840445504
commit 4dff4b0c02
6 changed files with 40 additions and 38 deletions

View File

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

View File

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

View File

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

View File

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

View File

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