Compare commits
2 Commits
33140dde73
...
e858caf981
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e858caf981 | ||
|
|
758ab26526 |
18
migratorapi/api/migrations/0010_migration_term_date.py
Normal file
18
migratorapi/api/migrations/0010_migration_term_date.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# 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,6 +23,8 @@ 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,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