49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
from rest_framework import serializers
|
|
from .models import Migration
|
|
import datetime
|
|
|
|
# class MigrationOverView(serializers.ModelSerializer):
|
|
# booked_count = serializers.SerializerMethodField()
|
|
# missed_count = serializers.SerializerMethodField()
|
|
# awaitterm_count = serializers.SerializerMethodField()
|
|
# complete_count = serializers.SerializerMethodField()
|
|
# class Meta:
|
|
# model = Migration
|
|
# fields = ['booked_count',
|
|
# 'missed_count',
|
|
# 'awaitterm_count',
|
|
# 'complete_count']
|
|
|
|
# def get_booked_count (self, obj):
|
|
# return Migration.objects.filter(migration_status="Booked").count()
|
|
|
|
# def get_missed_count (self, obj):
|
|
# return Migration.objects.filter(migration_status="Booked", booked_date__lt=datetime.datetime.now().date()).count()
|
|
|
|
# def get_awaitterm_count (self, obj):
|
|
# return Migration.objects.filter(migration_status="Waiting Termination", booked_date=datetime.datetime.now().date()).count()
|
|
|
|
# def get_complete_count (self, obj):
|
|
# return Migration.objects.filter(migration_status="Completed").count()
|
|
|
|
class MigrationSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Migration
|
|
fields = ['id',
|
|
'submit_time',
|
|
'domain',
|
|
'booked_date',
|
|
'booked_time',
|
|
'original_server',
|
|
'new_server',
|
|
'username',
|
|
'notes',
|
|
'brand',
|
|
'ticket_id',
|
|
'migration_status',
|
|
'agent_booked',
|
|
'additional_domains',
|
|
'migration_type',
|
|
'term_date',
|
|
'migration_cmd',
|
|
'extra_scripts_run'] |