Move api lower
This commit is contained in:
parent
4840445504
commit
4dff4b0c02
7
stagestatus/apps/machines/api/routers.py
Normal file
7
stagestatus/apps/machines/api/routers.py
Normal 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)
|
32
stagestatus/apps/machines/api/viewsets.py
Normal file
32
stagestatus/apps/machines/api/viewsets.py
Normal 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()
|
@ -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)
|
@ -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):
|
||||
|
@ -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()
|
Loading…
Reference in New Issue
Block a user