Compare commits
No commits in common. "e858caf98130b07c7f146b30e3168f8a82d412b2" and "33140dde7322fd7eae0669519818589ddd11cca3" have entirely different histories.
e858caf981
...
33140dde73
@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 3.1.2 on 2020-10-22 22:20
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0009_migration_is_urgent'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='migration',
|
|
||||||
name='term_date',
|
|
||||||
field=models.DateField(blank=True, null=True, verbose_name='Date to be terminated'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@ -23,8 +23,6 @@ class Migration(models.Model):
|
|||||||
additional_domains = models.CharField(
|
additional_domains = models.CharField(
|
||||||
max_length=500, null=True, blank=True)
|
max_length=500, null=True, blank=True)
|
||||||
migration_type = models.CharField(max_length=200)
|
migration_type = models.CharField(max_length=200)
|
||||||
term_date = models.DateField(
|
|
||||||
'Date to be terminated', null=True, blank=True)
|
|
||||||
is_urgent = models.BooleanField(default=False)
|
is_urgent = models.BooleanField(default=False)
|
||||||
|
|
||||||
def print_missed_migrations(self):
|
def print_missed_migrations(self):
|
||||||
|
|||||||
@ -21,32 +21,22 @@ class MigrationViewSet(viewsets.ModelViewSet):
|
|||||||
# permission_classes = (AllowAny,)
|
# permission_classes = (AllowAny,)
|
||||||
|
|
||||||
@action(detail=False, methods=['GET'])
|
@action(detail=False, methods=['GET'])
|
||||||
def upcoming(self, request):
|
def upcoming(self, request, *args, **kwargs):
|
||||||
''' 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.objects.filter(booked_time=timezone.now(), 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'])
|
@action(detail=False, methods=['GET'])
|
||||||
def missed(self, request):
|
def missed(self, request, *args, **kwargs):
|
||||||
''' Returns a list of the missed migrations (Still have the status
|
''' Returns a list of the missed migrations (Still have the status booked and date is greater then today) '''
|
||||||
booked and date is greater then today) '''
|
|
||||||
queryset = MigrationSerializer(
|
queryset = MigrationSerializer(
|
||||||
Migration.objects.filter(booked_time__gte=timezone.now() + datetime.timedelta(1),
|
Migration.objects.filter(booked_time__gte=timezone.now() + datetime.timedelta(1), 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'])
|
@action(detail=False, methods=['GET'])
|
||||||
def booked(self, request):
|
def booked(self, request, *args, **kwargs):
|
||||||
''' 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