mirror of
https://github.com/lemeow125/EquipmentTracker-Backend.git
synced 2024-11-17 06:09:26 +08:00
27 lines
891 B
Python
27 lines
891 B
Python
from rest_framework.permissions import IsAuthenticated
|
|
from rest_framework import viewsets, generics
|
|
from .models import EquipmentGroup
|
|
from . import serializers
|
|
from config.settings import DEBUG
|
|
from accounts.permissions import IsTechnician
|
|
|
|
# -- Equipment Viewsets
|
|
|
|
|
|
class EquipmentGroupViewSet(viewsets.ModelViewSet):
|
|
if (not DEBUG):
|
|
permission_classes = [IsAuthenticated, IsTechnician]
|
|
serializer_class = serializers.EquipmentGroupSerializer
|
|
queryset = EquipmentGroup.objects.all().order_by('id')
|
|
|
|
# Last changed equipment
|
|
|
|
|
|
class LastUpdatedEquipmentGroupViewSet(generics.ListAPIView):
|
|
if (not DEBUG):
|
|
permission_classes = [IsAuthenticated, IsTechnician]
|
|
serializer_class = serializers.EquipmentGroupSerializer
|
|
queryset = EquipmentGroup.objects.all().order_by('-date_added')
|
|
|
|
def get_queryset(self):
|
|
return super().get_queryset()[:1]
|