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)
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)
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)
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)
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)
def to_representation(self, instance): response = super(MarketParticipantTradesSerializer, self).to_representation(instance) return remove_null_values(response)
def to_representation(self, instance): response = super().to_representation(instance) return remove_null_values(response)