Compare commits
No commits in common. "ceee052a90e07c689d8f7f3fc25e30aa9863ab12" and "210fefeaf1382fb9d1ce9dc5577a74eaba4f1603" have entirely different histories.
ceee052a90
...
210fefeaf1
@ -24,13 +24,7 @@ def checkLimit(limit):
|
|||||||
limit = int(limit)
|
limit = int(limit)
|
||||||
return limit
|
return limit
|
||||||
|
|
||||||
def checkValue(value):
|
def checkDays(days):
|
||||||
if value:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def checkDayNumber(days):
|
|
||||||
if days == "":
|
if days == "":
|
||||||
days = 0
|
days = 0
|
||||||
else:
|
else:
|
||||||
@ -110,7 +104,7 @@ class MigrationsWaitingTerm(APIView):
|
|||||||
Returns list of booked migrations
|
Returns list of booked migrations
|
||||||
'''
|
'''
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
days = checkDayNumber(request.GET.get('days', ''))
|
days = checkDays(request.GET.get('days', ''))
|
||||||
limit = checkLimit(request.GET.get('limit', ''))
|
limit = checkLimit(request.GET.get('limit', ''))
|
||||||
migrations = MigrationSerializer(Migration.objects.filter(migration_status="Waiting Termination", term_date=datetime.datetime.now().date() + datetime.timedelta(days))[:limit], many=True)
|
migrations = MigrationSerializer(Migration.objects.filter(migration_status="Waiting Termination", term_date=datetime.datetime.now().date() + datetime.timedelta(days))[:limit], many=True)
|
||||||
return Response(migrations.data, status=status.HTTP_200_OK)
|
return Response(migrations.data, status=status.HTTP_200_OK)
|
||||||
@ -131,7 +125,7 @@ class PendingMigrations(APIView):
|
|||||||
are booked for today (maybe before timezone.now))
|
are booked for today (maybe before timezone.now))
|
||||||
'''
|
'''
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
days = checkDayNumber(request.GET.get('days', ''))
|
days = checkDays(request.GET.get('days', ''))
|
||||||
limit = checkLimit(request.GET.get('limit', ''))
|
limit = checkLimit(request.GET.get('limit', ''))
|
||||||
migrations = Migration.objects.filter(
|
migrations = Migration.objects.filter(
|
||||||
migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(days)
|
migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(days)
|
||||||
@ -172,30 +166,13 @@ class MigrationListAll(APIView):
|
|||||||
|
|
||||||
class MigrationTimeslotDetails(APIView):
|
class MigrationTimeslotDetails(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
#TODO: FIX THIS GARBAGE I HATE IT
|
slotDict = {}
|
||||||
# 5 days starting day before - Return Array of arrays
|
days = checkDays(request.GET.get('days', ''))
|
||||||
day = checkDayNumber(request.GET.get('day', ''))
|
|
||||||
days = checkDayNumber(request.GET.get('noOfDays', ''))
|
|
||||||
# timeslots = ['00:00-03:00', '03:00-06:00', '06:00-09:00', '08:00-12:00', '12:00-18:00', '18:00-00:00']
|
# timeslots = ['00:00-03:00', '03:00-06:00', '06:00-09:00', '08:00-12:00', '12:00-18:00', '18:00-00:00']
|
||||||
timeslots = settings.MIG_TIMESLOTS
|
timeslots = settings.MIG_TIMESLOTS
|
||||||
if checkValue(request.GET.get('values', '')):
|
for slot in timeslots:
|
||||||
slotArray = []
|
slotDict[slot] = Migration.objects.filter(migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(days), booked_time=slot).count()
|
||||||
if days:
|
return Response(slotDict)
|
||||||
daySlotArray = []
|
|
||||||
for daynum in range(days):
|
|
||||||
for slot in timeslots:
|
|
||||||
slotArray.append(Migration.objects.filter(migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(daynum -1), booked_time=slot).count())
|
|
||||||
daySlotArray.append(slotArray)
|
|
||||||
slotArray = []
|
|
||||||
return Response(daySlotArray)
|
|
||||||
for slot in timeslots:
|
|
||||||
slotArray.append(Migration.objects.filter(migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(day), booked_time=slot).count())
|
|
||||||
return Response(slotArray)
|
|
||||||
else:
|
|
||||||
slotDict = {}
|
|
||||||
for slot in timeslots:
|
|
||||||
slotDict[slot] = Migration.objects.filter(migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(day), booked_time=slot).count()
|
|
||||||
return Response(slotDict)
|
|
||||||
|
|
||||||
|
|
||||||
class getTimeslots(APIView):
|
class getTimeslots(APIView):
|
||||||
|
|||||||
Reference in New Issue
Block a user