from changes.api.serializer import Serializer, register
from changes.models import Command


@register(Command)
class CommandSerializer(Serializer):
    def serialize(self, instance, attrs):
        return {
            'id': instance.id.hex,
            'name': instance.label,
            'status': instance.status,
            'script': instance.script,
            'returnCode': instance.return_code,
            'env': dict(instance.env or {}),
            'cwd': instance.cwd,
            'artifacts': instance.artifacts or [],
            'duration': instance.duration,
            'dateCreated': instance.date_created,
            'dateStarted': instance.date_started,
            'dateFinished': instance.date_finished,
        }

from changes.api.serializer import Serializer, register
from changes.models import Command


@register(Command)
class CommandSerializer(Serializer):
    def serialize(self, instance, attrs):
        return {
            'id': instance.id.hex,
            'name': instance.label,
            'status': instance.status,
            'script': instance.script,
            'returnCode': instance.return_code,
            'env': dict(instance.env or {}),
            'cwd': instance.cwd,
            'type': instance.type,
            'artifacts': instance.artifacts or [],
            'duration': instance.duration,
            'dateCreated': instance.date_created,
            'dateStarted': instance.date_started,
            'dateFinished': instance.date_finished,
        }

Add type to command serialization