Exemple #1
0
class InstanceStatusHistorySerializer(serializers.HyperlinkedModelSerializer):
    instance = InstanceRelatedField(queryset=Instance.objects.none())
    size = SizeRelatedField(queryset=Size.objects.none())
    provider = ProviderSummarySerializer(
        source='instance.provider_machine.provider')
    image = ImageSummarySerializer(
        source='instance.provider_machine.application_version.application')
    status = serializers.SlugRelatedField(slug_field='name', read_only=True)
    url = UUIDHyperlinkedIdentityField(
        view_name='api:v2:instancestatushistory-detail',
    )

    class Meta:
        model = InstanceStatusHistory
        fields = (
            'id',
            'uuid',
            'url',
            'instance',
            'status',
            'size',
            'provider',
            'image',
            'start_date',
            'end_date',
        )
class InstanceStatusHistorySerializer(serializers.HyperlinkedModelSerializer):
    instance = ModelRelatedField(
        queryset=Instance.objects.all(),
        serializer_class=InstanceSuperSummarySerializer,
        style={'base_template': 'input.html'})
    size = SizeRelatedField(queryset=Size.objects.none())
    provider = ProviderSummarySerializer(source='instance.get_provider')
    image = ImageSummarySerializer(
        source='instance.provider_machine.application_version.application')
    status = serializers.SlugRelatedField(slug_field='name', read_only=True)
    activity = serializers.CharField(max_length=36, allow_blank=True)
    url = UUIDHyperlinkedIdentityField(
        view_name='api:v2:instancestatushistory-detail', )

    class Meta:
        model = InstanceStatusHistory
        fields = (
            'id',
            'uuid',
            'url',
            'instance',
            'status',
            'activity',
            'size',
            'provider',
            'image',
            'extra',
            'start_date',
            'end_date',
        )