Remove PreserveGetQuerySet mixin. Update SingleObjectList and

MultipleObjectFormActionView views to use a new get_object_list method.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-08-16 22:11:22 -04:00
parent c43f5eb66e
commit 2052caada4
39 changed files with 540 additions and 508 deletions

View File

@@ -82,7 +82,7 @@ class DocumentsViewsTestCase(GenericDocumentViewTestCase):
response = self.get('documents:document_list')
self.assertContains(response, 'Total: 0', status_code=200)
def test_document_list_view_with_permissions(self):
def test_document_list_view_with_access(self):
self.grant_access(
obj=self.document, permission=permission_document_view
)

View File

@@ -41,9 +41,6 @@ class DocumentPageListView(SingleObjectListView):
def get_document(self):
return get_object_or_404(Document, pk=self.kwargs['pk'])
def get_queryset(self):
return self.get_document().pages.all()
def get_extra_context(self):
return {
'list_as_items': True,
@@ -51,6 +48,9 @@ class DocumentPageListView(SingleObjectListView):
'title': _('Pages for document: %s') % self.get_document(),
}
def get_object_list(self):
return self.get_document().pages.all()
class DocumentPageNavigationBase(RedirectView):
def dispatch(self, request, *args, **kwargs):

View File

@@ -196,5 +196,5 @@ class DocumentTypeFilenameListView(SingleObjectListView):
) % self.get_document_type(),
}
def get_queryset(self):
def get_object_list(self):
return self.get_document_type().filenames.all()

View File

@@ -47,7 +47,7 @@ class DocumentVersionListView(SingleObjectListView):
'title': _('Versions of document: %s') % self.get_document(),
}
def get_queryset(self):
def get_object_list(self):
return self.get_document().versions.order_by('-timestamp')

View File

@@ -64,7 +64,7 @@ class DocumentListView(SingleObjectListView):
'title': _('All documents'),
}
def get_queryset(self):
def get_object_list(self):
return self.get_document_queryset().filter(is_stub=False)
@@ -203,7 +203,7 @@ class DocumentDuplicatesListView(DocumentListView):
)
return context
def get_queryset(self):
def get_object_list(self):
try:
return DuplicatedDocument.objects.get(
document=self.get_document()