Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #12 from myarik/release_0.3.2
Browse files Browse the repository at this point in the history
Release 0.3.2
  • Loading branch information
myarik authored Sep 6, 2017
2 parents a49ab30 + 1f12810 commit e79b774
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from rest_framework_elasticsearch import es_views, es_pagination, es_filters
class BlogView(es_views.ListElasticAPIView):
es_client = es_client
es_model = BlogIndex
es_paginator = es_pagination.ElasticLimitOffsetPagination()
es_paginator_class = es_pagination.ElasticLimitOffsetPagination
es_filter_backends = (
es_filters.ElasticFieldsFilter,
es_filters.ElasticSearchFilter,
Expand Down
2 changes: 1 addition & 1 deletion docs/ordering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Example of ordering
es_client = Elasticsearch(hosts=['elasticsearch:9200/'],
connection_class=RequestsHttpConnection)
es_paginator = es_pagination.ElasticLimitOffsetPagination()
es_paginator_class = es_pagination.ElasticLimitOffsetPagination
es_filter_backends = (
es_filters.ElasticFieldsFilter,
Expand Down
2 changes: 1 addition & 1 deletion docs/pagination.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Example of the pagination response
es_client = Elasticsearch(hosts=['elasticsearch:9200/'],
connection_class=RequestsHttpConnection)
es_paginator = es_pagination.ElasticLimitOffsetPagination()
es_paginator_class = es_pagination.ElasticLimitOffsetPagination
es_model = BlogIndex
es_filter_backends = (
Expand Down
2 changes: 1 addition & 1 deletion example_project/example_project/blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class BlogView(es_views.ListElasticAPIView):
es_client = es_client
es_model = BlogIndex
es_paginator = es_pagination.ElasticLimitOffsetPagination()
es_paginator_class = es_pagination.ElasticLimitOffsetPagination

es_filter_backends = (
es_filters.ElasticFieldsFilter,
Expand Down
2 changes: 1 addition & 1 deletion example_project/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ redis>=2.10.5
# Django Rest Framework
djangorestframework==3.6.2
django-filter==1.0.1
django-rest-elasticsearch==0.3.1
django-rest-elasticsearch==0.3.2

# Your custom requirements go here
4 changes: 1 addition & 3 deletions rest_framework_elasticsearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
__title__ = 'rest_framework_elasticsearch'
__version__ = '0.3.1'
__version__ = '0.3.2'
__author__ = 'Yaroslav Muravskyi'

# Version synonym
VERSION = __version__


15 changes: 14 additions & 1 deletion rest_framework_elasticsearch/es_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ListElasticMixin(object):
es_client = None

es_model = None
es_paginator = None
es_paginator_class = None

es_filter_backends = ()
es_excludes_fields = ()

Expand Down Expand Up @@ -60,6 +61,18 @@ def es_representation(iterable):
item.to_dict() for item in iterable
]

@property
def es_paginator(self):
"""
The es_paginator instance associated with the view
"""
if not hasattr(self, '_es_paginator'):
if self.es_paginator_class is None:
self._es_paginator = None
else:
self._es_paginator = self.es_paginator_class()
return self._es_paginator

def paginate_search(self, search):
"""
Return a single page of results, or `None` if pagination is disabled.
Expand Down

0 comments on commit e79b774

Please sign in to comment.