'''
Created on Apr 10, 2013

@author: egiraldo
'''
from django.forms import widgets
from rest_framework import serializers
from rel_actividad.models import Rel_Actividad
class RelActividadSerializer(serializers.Serializer):
    id_rel_actividad = serializers.Field()  # Note: `Field` is an untyped read-only field.
    id_actividad_padre = serializers.Field()  # Note: `Field` is an untyped read-only field.
    id_actividad_hijo = serializers.Field()  # Note: `Field` is an untyped read-only field.
    id_workflow = serializers.Field()  # Note: `Field` is an untyped read-only field.
    def restore_object(self, attrs, instance=None):
        if instance:
            # Update existing instance
            instance.id_actividad_padre = attrs.get('id_actividad_padre', instance.id_actividad_padre)
            instance.id_actividad_hijo = attrs.get('id_actividad_hijo', instance.id_actividad_hijo)
            instance.id_workflow = attrs.get('id_workflow', instance.id_workflow)
            return instance
        # Create new instance
        return Workflow_Transaccion(**attrs)
