Compare commits
2 Commits
210fefeaf1
...
ceee052a90
| Author | SHA1 | Date | |
|---|---|---|---|
| ceee052a90 | |||
| d4e6a67d42 |
@ -24,7 +24,13 @@ def checkLimit(limit):
|
|||||||
limit = int(limit)
|
limit = int(limit)
|
||||||
return limit
|
return limit
|
||||||
|
|
||||||
def checkDays(days):
|
def checkValue(value):
|
||||||
|
if value:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def checkDayNumber(days):
|
||||||
if days == "":
|
if days == "":
|
||||||
days = 0
|
days = 0
|
||||||
else:
|
else:
|
||||||
@ -104,7 +110,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 = checkDays(request.GET.get('days', ''))
|
days = checkDayNumber(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)
|
||||||
@ -125,7 +131,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 = checkDays(request.GET.get('days', ''))
|
days = checkDayNumber(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)
|
||||||
@ -166,12 +172,29 @@ class MigrationListAll(APIView):
|
|||||||
|
|
||||||
class MigrationTimeslotDetails(APIView):
|
class MigrationTimeslotDetails(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
slotDict = {}
|
#TODO: FIX THIS GARBAGE I HATE IT
|
||||||
days = checkDays(request.GET.get('days', ''))
|
# 5 days starting day before - Return Array of arrays
|
||||||
|
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', '')):
|
||||||
|
slotArray = []
|
||||||
|
if days:
|
||||||
|
daySlotArray = []
|
||||||
|
for daynum in range(days):
|
||||||
for slot in timeslots:
|
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()
|
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)
|
return Response(slotDict)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user