workout/gym/views.py

24 lines
710 B
Python
Raw Normal View History

2018-03-03 14:24:57 +01:00
from django.contrib.auth.models import User
from rest_framework import viewsets
from rest_framework.generics import RetrieveUpdateAPIView
2018-03-02 12:01:51 +01:00
2018-03-03 14:24:57 +01:00
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