workout/gym/views.py
2018-03-03 14:24:57 +01:00

24 lines
No EOL
710 B
Python

from django.contrib.auth.models import User
from rest_framework import viewsets
from rest_framework.generics import RetrieveUpdateAPIView
from gym.models import Room, Equipment
from gym.serializers import RoomSerializer, EquipmentSerializer, UserSerializer
class MeView(RetrieveUpdateAPIView):
serializer_class = UserSerializer
queryset = User.objects.none()
def get_object(self):
return self.request.user
class RoomViewSet(viewsets.ModelViewSet):
queryset = Room.objects.all().order_by('name')
serializer_class = RoomSerializer
class EquipmentViewSet(viewsets.ModelViewSet):
queryset = Equipment.objects.all().order_by('name')
serializer_class = EquipmentSerializer