예제 #1
0
    def to_representation(self, instance):
        result = {
            'title': instance.title,
            'description': instance.description,
            'resolution_date': instance.resolution_date,
            'ipfs_hash': instance.ipfs_hash
        }
        if isinstance(instance, ScalarEventDescription):
            scalar_event = instance
            result['unit'] = scalar_event.unit
            result['decimals'] = scalar_event.decimals
            return remove_null_values(result)
        elif isinstance(instance, CategoricalEventDescription):
            categorical_event = instance
            result['outcomes'] = categorical_event.outcomes
            return remove_null_values(result)
        try:
            scalar_event = instance.scalareventdescription
            result['unit'] = scalar_event.unit
            result['decimals'] = scalar_event.decimals
        except:
            categorical_event = instance.categoricaleventdescription
            result['outcomes'] = categorical_event.outcomes

        return remove_null_values(result)
예제 #2
0
 def to_representation(self, instance):
     try:
         categorical_event = instance.categoricalevent
         result = CategoricalEventSerializer(
             categorical_event).to_representation(categorical_event)
         return remove_null_values(result)
     except:
         scalar_event = instance.scalarevent
         result = ScalarEventSerializer(scalar_event).to_representation(
             scalar_event)
         return remove_null_values(result)
예제 #3
0
    def to_representation(self, instance):
        result = None
        try:
            categorical_event = CategoricalEvent.objects.get(address=instance.address)
            result = CategoricalEventSerializer(categorical_event).to_representation(categorical_event)
            return remove_null_values(result)
        except CategoricalEvent.DoesNotExist:
            pass

        try:
            scalar_event = ScalarEvent.objects.get(address=instance.address)
            result = ScalarEventSerializer(scalar_event).to_representation(scalar_event)
            return remove_null_values(result)
        except ScalarEvent.DoesNotExist:
            pass
예제 #4
0
    def to_representation(self, instance):
        result = None
        try:
            centralized_oracle = CentralizedOracle.objects.get(address=instance.address)
            result = CentralizedOracleSerializer(centralized_oracle).to_representation(centralized_oracle)
            return remove_null_values(result)
        except CentralizedOracle.DoesNotExist:
            pass

        try:
            ultimate_oracle = UltimateOracle.objects.get(address=instance.address)
            result = UltimateOracleSerializer(ultimate_oracle).to_representation(ultimate_oracle)
            return remove_null_values(result)
        except UltimateOracle.DoesNotExist:
            response = super(OracleSerializer, self).to_representation(instance)
            return remove_null_values(response)
예제 #5
0
 def to_representation(self, instance):
     if isinstance(instance, CentralizedOracle):
         centralized_oracle = instance
     else:
         centralized_oracle = instance.centralizedoracle
     response = CentralizedOracleSerializer(
         centralized_oracle).to_representation(centralized_oracle)
     return remove_null_values(response)
예제 #6
0
    def to_representation(self, instance):
        response = {
            'address': add_0x_prefix(instance.address),
            'factory_address': add_0x_prefix(instance.factory),
            'creator': add_0x_prefix(instance.creator),
            'creation_date': instance.creation_date_time,
            'creation_block': instance.creation_block
        }

        return remove_null_values(response)
예제 #7
0
    def to_representation(self, instance):
        result = {
            'title': instance.title,
            'description': instance.description,
            'resolution_date': instance.resolution_date,
            'ipfs_hash': instance.ipfs_hash
        }

        try:
            scalar_event = ScalarEventDescription.objects.get(id=instance.id)
            result['unit'] = scalar_event.unit
            result['decimals'] = scalar_event.decimals
        except ObjectDoesNotExist:
            pass

        try:
            categorical_event = CategoricalEventDescription.objects.get(id=instance.id)
            result['outcomes'] = categorical_event.outcomes
        except ObjectDoesNotExist:
            pass

        return remove_null_values(result)
예제 #8
0
 def to_representation(self, instance):
     # Prepend 0x prefix to owner
     instance.owner = add_0x_prefix(instance.owner)
     response = super(CentralizedOracleSerializer, self).to_representation(instance)
     return remove_null_values(response)
예제 #9
0
 def to_representation(self, instance):
     response = super(MarketParticipantHistorySerializer, self).to_representation(instance)
     return remove_null_values(response)
예제 #10
0
 def to_representation(self, instance):
     # Prepend 0x prefix to collateral_token
     instance.owner = add_0x_prefix(instance.collateral_token)
     response = super(UltimateOracleSerializer, self).to_representation(instance)
     return remove_null_values(response)
예제 #11
0
 def to_representation(self, instance):
     response = super(MarketTradesSerializer,
                      self).to_representation(instance)
     return remove_null_values(response)
예제 #12
0
 def to_representation(self, instance):
     centralized_oracle = CentralizedOracle.objects.get(
         address=instance.address)
     response = CentralizedOracleSerializer(
         centralized_oracle).to_representation(centralized_oracle)
     return remove_null_values(response)