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)
|
||||
return limit
|
||||
|
||||
def checkValue(value):
|
||||
if value:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkDayNumber(days):
|
||||
def checkDays(days):
|
||||
if days == "":
|
||||
days = 0
|
||||
else:
|
||||
@ -110,7 +104,7 @@ class MigrationsWaitingTerm(APIView):
|
||||
Returns list of booked migrations
|
||||
'''
|
||||
def get(self, request, format=None):
|
||||
days = checkDayNumber(request.GET.get('days', ''))
|
||||
days = checkDays(request.GET.get('days', ''))
|
||||
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)
|
||||
return Response(migrations.data, status=status.HTTP_200_OK)
|
||||
@ -131,7 +125,7 @@ class PendingMigrations(APIView):
|
||||
are booked for today (maybe before timezone.now))
|
||||
'''
|
||||
def get(self, request, format=None):
|
||||
days = checkDayNumber(request.GET.get('days', ''))
|
||||
days = checkDays(request.GET.get('days', ''))
|
||||
limit = checkLimit(request.GET.get('limit', ''))
|
||||
migrations = Migration.objects.filter(
|
||||
migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(days)
|
||||
@ -172,30 +166,13 @@ class MigrationListAll(APIView):
|
||||
|
||||
class MigrationTimeslotDetails(APIView):
|
||||
def get(self, request):
|
||||
#TODO: FIX THIS GARBAGE I HATE IT
|
||||
# 5 days starting day before - Return Array of arrays
|
||||
day = checkDayNumber(request.GET.get('day', ''))
|
||||
days = checkDayNumber(request.GET.get('noOfDays', ''))
|
||||
slotDict = {}
|
||||
days = checkDays(request.GET.get('days', ''))
|
||||
# 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
|
||||
if checkValue(request.GET.get('values', '')):
|
||||
slotArray = []
|
||||
if days:
|
||||
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)
|
||||
for slot in timeslots:
|
||||
slotDict[slot] = Migration.objects.filter(migration_status="Booked", booked_date=datetime.datetime.now().date() + datetime.timedelta(days), booked_time=slot).count()
|
||||
return Response(slotDict)
|
||||
|
||||
|
||||
class getTimeslots(APIView):
|
||||
|
||||
Reference in New Issue
Block a user