Tag types
This commit is contained in:
parent
ca61359a81
commit
bff533e7d5
|
|
@ -89,10 +89,6 @@ class EstablishmentDocumentViewSet(BaseDocumentViewSet):
|
||||||
search_fields = {
|
search_fields = {
|
||||||
'name': {'fuzziness': 'auto:2,5',
|
'name': {'fuzziness': 'auto:2,5',
|
||||||
'boost': 4},
|
'boost': 4},
|
||||||
'transliterated_name': {'fuzziness': 'auto:2,5',
|
|
||||||
'boost': 3},
|
|
||||||
'index_name': {'fuzziness': 'auto:2,5',
|
|
||||||
'boost': 2},
|
|
||||||
'description': {'fuzziness': 'auto:2,5'},
|
'description': {'fuzziness': 'auto:2,5'},
|
||||||
}
|
}
|
||||||
translated_search_fields = (
|
translated_search_fields = (
|
||||||
|
|
@ -199,7 +195,7 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
"""Product document ViewSet."""
|
"""Product document ViewSet."""
|
||||||
|
|
||||||
document = ProductDocument
|
document = ProductDocument
|
||||||
lookup_field = 'slug'
|
# lookup_field = 'slug'
|
||||||
pagination_class = ProjectMobilePagination
|
pagination_class = ProjectMobilePagination
|
||||||
permission_classes = (permissions.AllowAny,)
|
permission_classes = (permissions.AllowAny,)
|
||||||
serializer_class = serializers.ProductDocumentSerializer
|
serializer_class = serializers.ProductDocumentSerializer
|
||||||
|
|
@ -212,8 +208,8 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
filter_backends = [
|
filter_backends = [
|
||||||
FilteringFilterBackend,
|
FilteringFilterBackend,
|
||||||
filters.CustomSearchFilterBackend,
|
filters.CustomSearchFilterBackend,
|
||||||
GeoSpatialFilteringFilterBackend,
|
# GeoSpatialFilteringFilterBackend,
|
||||||
DefaultOrderingFilterBackend,
|
# DefaultOrderingFilterBackend,
|
||||||
]
|
]
|
||||||
|
|
||||||
search_fields = {
|
search_fields = {
|
||||||
|
|
@ -221,10 +217,9 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
'boost': 4},
|
'boost': 4},
|
||||||
'transliterated_name': {'fuzziness': 'auto:2,5',
|
'transliterated_name': {'fuzziness': 'auto:2,5',
|
||||||
'boost': 3},
|
'boost': 3},
|
||||||
'index_name': {'fuzziness': 'auto:2,5',
|
|
||||||
'boost': 2},
|
|
||||||
'description': {'fuzziness': 'auto:2,5'},
|
'description': {'fuzziness': 'auto:2,5'},
|
||||||
}
|
}
|
||||||
|
|
||||||
translated_search_fields = (
|
translated_search_fields = (
|
||||||
'description',
|
'description',
|
||||||
)
|
)
|
||||||
|
|
@ -248,9 +243,6 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
'for_establishment': {
|
'for_establishment': {
|
||||||
'field': 'establishment.slug',
|
'field': 'establishment.slug',
|
||||||
},
|
},
|
||||||
'type': {
|
|
||||||
'field': 'product_type.index_name',
|
|
||||||
},
|
|
||||||
'product_type': {
|
'product_type': {
|
||||||
'field': 'product_type.index_name',
|
'field': 'product_type.index_name',
|
||||||
},
|
},
|
||||||
|
|
@ -262,5 +254,5 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
geo_spatial_filter_fields = {
|
# geo_spatial_filter_fields = {
|
||||||
}
|
# }
|
||||||
|
|
@ -31,13 +31,18 @@ class TagCategoryFilterSet(TagsBaseFilterSet):
|
||||||
"""TagCategory filterset."""
|
"""TagCategory filterset."""
|
||||||
|
|
||||||
establishment_type = filters.CharFilter(method='by_establishment_type')
|
establishment_type = filters.CharFilter(method='by_establishment_type')
|
||||||
|
product_type = filters.CharFilter(method='by_product_type')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Meta class."""
|
"""Meta class."""
|
||||||
|
|
||||||
model = models.TagCategory
|
model = models.TagCategory
|
||||||
fields = ('type',
|
fields = ('type',
|
||||||
'establishment_type', )
|
'establishment_type',
|
||||||
|
'product_type', )
|
||||||
|
|
||||||
|
def by_product_type(self, queryset, name, value):
|
||||||
|
return queryset.by_product_type(value)
|
||||||
|
|
||||||
# todo: filter by establishment type
|
# todo: filter by establishment type
|
||||||
def by_establishment_type(self, queryset, name, value):
|
def by_establishment_type(self, queryset, name, value):
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,10 @@ class TagCategoryQuerySet(models.QuerySet):
|
||||||
"""Filter by establishment type index name."""
|
"""Filter by establishment type index name."""
|
||||||
return self.filter(establishment_types__index_name=index_name)
|
return self.filter(establishment_types__index_name=index_name)
|
||||||
|
|
||||||
|
def by_product_type(self, index_name):
|
||||||
|
"""Filter by product type index name."""
|
||||||
|
return self.filter(product_types__index_name=index_name)
|
||||||
|
|
||||||
def with_tags(self, switcher=True):
|
def with_tags(self, switcher=True):
|
||||||
"""Filter by existing tags."""
|
"""Filter by existing tags."""
|
||||||
return self.exclude(tags__isnull=switcher)
|
return self.exclude(tags__isnull=switcher)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user