update establishment document index & establishment documentview
This commit is contained in:
parent
03c75efece
commit
3f233fd246
|
|
@ -10,16 +10,6 @@ EstablishmentIndex = Index(settings.ELASTICSEARCH_INDEX_NAMES.get(__name__,
|
||||||
EstablishmentIndex.settings(number_of_shards=1, number_of_replicas=1)
|
EstablishmentIndex.settings(number_of_shards=1, number_of_replicas=1)
|
||||||
|
|
||||||
|
|
||||||
# todo: check & refactor
|
|
||||||
class ObjectField(fields.ObjectField):
|
|
||||||
|
|
||||||
def get_value_from_instance(self, *args, **kwargs):
|
|
||||||
value = super(ObjectField, self).get_value_from_instance(*args, **kwargs)
|
|
||||||
if value == {}:
|
|
||||||
return None
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
@EstablishmentIndex.doc_type
|
@EstablishmentIndex.doc_type
|
||||||
class EstablishmentDocument(Document):
|
class EstablishmentDocument(Document):
|
||||||
"""Establishment document."""
|
"""Establishment document."""
|
||||||
|
|
@ -63,7 +53,7 @@ class EstablishmentDocument(Document):
|
||||||
'closed_at': fields.KeywordField(attr='closed_at_str'),
|
'closed_at': fields.KeywordField(attr='closed_at_str'),
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
address = ObjectField(
|
address = fields.ObjectField(
|
||||||
properties={
|
properties={
|
||||||
'id': fields.IntegerField(),
|
'id': fields.IntegerField(),
|
||||||
'street_name_1': fields.TextField(
|
'street_name_1': fields.TextField(
|
||||||
|
|
@ -93,13 +83,6 @@ class EstablishmentDocument(Document):
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
# todo: need to fix
|
|
||||||
# collections = fields.ObjectField(
|
|
||||||
# properties={
|
|
||||||
# 'id': fields.IntegerField(attr='collection.id'),
|
|
||||||
# 'collection_type': fields.IntegerField(attr='collection.collection_type'),
|
|
||||||
# },
|
|
||||||
# multi=True)
|
|
||||||
|
|
||||||
class Django:
|
class Django:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ class TagsDocumentSerializer(serializers.Serializer):
|
||||||
label_translated = serializers.SerializerMethodField()
|
label_translated = serializers.SerializerMethodField()
|
||||||
|
|
||||||
def get_label_translated(self, obj):
|
def get_label_translated(self, obj):
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
return get_translated_value(obj.get('label'))
|
||||||
return get_translated_value(obj.label)
|
return get_translated_value(obj.label)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,6 +31,11 @@ class AddressDocumentSerializer(serializers.Serializer):
|
||||||
geo_lon = serializers.FloatField(allow_null=True, source='coordinates.lon')
|
geo_lon = serializers.FloatField(allow_null=True, source='coordinates.lon')
|
||||||
geo_lat = serializers.FloatField(allow_null=True, source='coordinates.lat')
|
geo_lat = serializers.FloatField(allow_null=True, source='coordinates.lat')
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
if len(instance) != 0:
|
||||||
|
return super().to_representation(instance)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ScheduleDocumentSerializer(serializers.Serializer):
|
class ScheduleDocumentSerializer(serializers.Serializer):
|
||||||
"""Schedule serializer for ES Document"""
|
"""Schedule serializer for ES Document"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user