Added awaiting term view
This commit is contained in:
parent
758ab26526
commit
e858caf981
@ -21,22 +21,32 @@ class MigrationViewSet(viewsets.ModelViewSet):
|
|||||||
# permission_classes = (AllowAny,)
|
# permission_classes = (AllowAny,)
|
||||||
|
|
||||||
@action(detail=False, methods=['GET'])
|
@action(detail=False, methods=['GET'])
|
||||||
def upcoming(self, request, *args, **kwargs):
|
def upcoming(self, request):
|
||||||
''' Returns a list of the migrations due today '''
|
''' Returns a list of the migrations due today '''
|
||||||
queryset = MigrationSerializer(
|
queryset = MigrationSerializer(
|
||||||
Migration.objects.filter(booked_time=timezone.now(), migration_status="Booked"), many=True)
|
Migration.objects.filter(booked_time=timezone.now(),
|
||||||
|
migration_status="Booked"), many=True)
|
||||||
return Response(queryset.data, status=status.HTTP_200_OK)
|
return Response(queryset.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
@action(detail=False, methods=['GET'])
|
@action(detail=False, methods=['GET'])
|
||||||
def missed(self, request, *args, **kwargs):
|
def missed(self, request):
|
||||||
''' Returns a list of the missed migrations (Still have the status booked and date is greater then today) '''
|
''' Returns a list of the missed migrations (Still have the status
|
||||||
|
booked and date is greater then today) '''
|
||||||
queryset = MigrationSerializer(
|
queryset = MigrationSerializer(
|
||||||
Migration.objects.filter(booked_time__gte=timezone.now() + datetime.timedelta(1), migration_status="Booked"), many=True)
|
Migration.objects.filter(booked_time__gte=timezone.now() + datetime.timedelta(1),
|
||||||
|
migration_status="Booked"), many=True)
|
||||||
return Response(queryset.data, status=status.HTTP_200_OK)
|
return Response(queryset.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
@action(detail=False, methods=['GET'])
|
@action(detail=False, methods=['GET'])
|
||||||
def booked(self, request, *args, **kwargs):
|
def booked(self, request):
|
||||||
''' Returns a list of the booked migrations '''
|
''' Returns a list of the booked migrations '''
|
||||||
queryset = MigrationSerializer(Migration.objects.filter(
|
queryset = MigrationSerializer(Migration.objects.filter(
|
||||||
migration_status="booked",), many=True)
|
migration_status="booked",), many=True)
|
||||||
return Response(queryset.data, status=status.HTTP_200_OK)
|
return Response(queryset.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
@action(detail=False, methods=['GET'])
|
||||||
|
def awaitterm(self, request):
|
||||||
|
''' Returns migrations awaiting termination '''
|
||||||
|
queryset = MigrationSerializer(Migration.objects.filter(
|
||||||
|
migration_status="Awaiting Termination", term_date__lte=timezone.now()), many=True)
|
||||||
|
return Response(queryset.data, status=status.HTTP_200_OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user