Remove queryset slicing hack from view
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
* Move the navigation and authentication templates to their
|
||||
respective apps.
|
||||
* Add dashboard app.
|
||||
* Remove queryset slicing hack from the Document list view.
|
||||
And slice the Recently Added Document queryset itself.
|
||||
|
||||
3.1.11 (2019-04-XX)
|
||||
===================
|
||||
|
||||
@@ -67,6 +67,8 @@ Other changes
|
||||
* Move the navigation and authentication templates to their
|
||||
respective apps.
|
||||
* Add dashboard app.
|
||||
* Remove queryset slicing hack from the Document list view.
|
||||
And slice the Recently Added Document queryset itself.
|
||||
|
||||
|
||||
Removals
|
||||
|
||||
@@ -66,7 +66,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class DocumentListView(SingleObjectListView):
|
||||
object_permission = permission_document_view
|
||||
queryset_slice = None
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
try:
|
||||
@@ -103,11 +102,7 @@ class DocumentListView(SingleObjectListView):
|
||||
}
|
||||
|
||||
def get_object_list(self):
|
||||
queryset = self.get_document_queryset().filter(is_stub=False)
|
||||
if self.queryset_slice:
|
||||
return queryset.__getitem__(slice(*self.queryset_slice))
|
||||
else:
|
||||
return queryset
|
||||
return self.get_document_queryset().filter(is_stub=False)
|
||||
|
||||
|
||||
class DocumentDocumentTypeEditView(MultipleObjectFormActionView):
|
||||
@@ -812,10 +807,12 @@ class RecentAccessDocumentListView(DocumentListView):
|
||||
|
||||
|
||||
class RecentAddedDocumentListView(DocumentListView):
|
||||
queryset_slice = (0, setting_recent_added_count.value)
|
||||
|
||||
def get_document_queryset(self):
|
||||
return Document.objects.order_by('-date_added')
|
||||
return Document.objects.filter(
|
||||
pk__in=Document.objects.order_by('-date_added')[
|
||||
:setting_recent_added_count.value
|
||||
].values('pk')
|
||||
). order_by('-date_added')
|
||||
|
||||
def get_extra_context(self):
|
||||
context = super(RecentAddedDocumentListView, self).get_extra_context()
|
||||
|
||||
Reference in New Issue
Block a user