Add views to display document list per document type and per workflow.
This commit is contained in:
@@ -10,7 +10,8 @@ from .views import (
|
||||
SetupWorkflowStateEditView, SetupWorkflowStateListView,
|
||||
SetupWorkflowTransitionListView, SetupWorkflowTransitionCreateView,
|
||||
SetupWorkflowTransitionDeleteView, SetupWorkflowTransitionEditView,
|
||||
WorkflowInstanceDetailView, WorkflowInstanceTransitionView
|
||||
WorkflowDocumentListView, WorkflowInstanceDetailView,
|
||||
WorkflowInstanceTransitionView
|
||||
)
|
||||
|
||||
urlpatterns = patterns(
|
||||
@@ -23,6 +24,7 @@ urlpatterns = patterns(
|
||||
url(r'^setup/create/$', SetupWorkflowCreateView.as_view(), name='setup_workflow_create'),
|
||||
url(r'^setup/(?P<pk>\d+)/edit/$', SetupWorkflowEditView.as_view(), name='setup_workflow_edit'),
|
||||
url(r'^setup/(?P<pk>\d+)/delete/$', SetupWorkflowDeleteView.as_view(), name='setup_workflow_delete'),
|
||||
url(r'^setup/(?P<pk>\d+)/documents/$', WorkflowDocumentListView.as_view(), name='setup_workflow_document_list'),
|
||||
url(r'^setup/(?P<pk>\d+)/document_types/$', SetupWorkflowDocumentTypesView.as_view(), name='setup_workflow_document_types'),
|
||||
url(r'^setup/(?P<pk>\d+)/states/$', SetupWorkflowStateListView.as_view(), name='setup_workflow_states'),
|
||||
url(r'^setup/(?P<pk>\d+)/states/create/$', SetupWorkflowStateCreateView.as_view(), name='setup_workflow_state_create'),
|
||||
|
||||
@@ -15,6 +15,7 @@ from common.views import (
|
||||
SingleObjectEditView, SingleObjectListView
|
||||
)
|
||||
from documents.models import Document
|
||||
from documents.views import DocumentListView
|
||||
from permissions import Permission
|
||||
|
||||
from .forms import (
|
||||
@@ -57,6 +58,28 @@ class DocumentWorkflowInstanceListView(SingleObjectListView):
|
||||
return context
|
||||
|
||||
|
||||
class WorkflowDocumentListView(DocumentListView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.workflow = get_object_or_404(Workflow, pk=self.kwargs['pk'])
|
||||
|
||||
try:
|
||||
Permission.check_permissions(request.user, [permission_workflow_view])
|
||||
except PermissionDenied:
|
||||
AccessControlList.objects.check_access(permission_workflow_view, request.user, self.workflow)
|
||||
|
||||
return super(WorkflowDocumentListView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_document_queryset(self):
|
||||
return Document.objects.filter(document_type__in=self.workflow.document_types.all())
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_links': True,
|
||||
'object': self.workflow,
|
||||
'title': _('Documents with the workflow: %s') % self.workflow
|
||||
}
|
||||
|
||||
|
||||
class WorkflowInstanceDetailView(SingleObjectListView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
try:
|
||||
|
||||
@@ -13,7 +13,8 @@ from .settings import setting_print_size, setting_display_size
|
||||
from .views import (
|
||||
DeletedDocumentDeleteView, DeletedDocumentListView, DocumentListView,
|
||||
DocumentManyDeleteView, DocumentManyRestoreView, DocumentPageListView,
|
||||
DocumentRestoreView, EmptyTrashCanView, RecentDocumentListView
|
||||
DocumentRestoreView, DocumentTypeDocumentListView, EmptyTrashCanView,
|
||||
RecentDocumentListView
|
||||
)
|
||||
|
||||
urlpatterns = patterns(
|
||||
@@ -70,7 +71,7 @@ urlpatterns = patterns(
|
||||
url(r'^type/create/$', 'document_type_create', name='document_type_create'),
|
||||
url(r'^type/(?P<document_type_id>\d+)/edit/$', 'document_type_edit', name='document_type_edit'),
|
||||
url(r'^type/(?P<document_type_id>\d+)/delete/$', 'document_type_delete', name='document_type_delete'),
|
||||
|
||||
url(r'^type/(?P<pk>\d+)/documents/$', DocumentTypeDocumentListView.as_view(), name='document_type_document_list'),
|
||||
url(r'^type/(?P<document_type_id>\d+)/filename/list/$', 'document_type_filename_list', name='document_type_filename_list'),
|
||||
url(r'^type/filename/(?P<document_type_filename_id>\d+)/edit/$', 'document_type_filename_edit', name='document_type_filename_edit'),
|
||||
url(r'^type/filename/(?P<document_type_filename_id>\d+)/delete/$', 'document_type_filename_delete', name='document_type_filename_delete'),
|
||||
|
||||
@@ -181,6 +181,21 @@ class DocumentPageListView(ParentChildListView):
|
||||
return context
|
||||
|
||||
|
||||
class DocumentTypeDocumentListView(DocumentListView):
|
||||
def get_document_type(self):
|
||||
return get_object_or_404(DocumentType, pk=self.kwargs['pk'])
|
||||
|
||||
def get_document_queryset(self):
|
||||
return self.get_document_type().documents.all()
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_links': True,
|
||||
'object': self.get_document_type(),
|
||||
'title': _('Documents of type: %s') % self.get_document_type()
|
||||
}
|
||||
|
||||
|
||||
class EmptyTrashCanView(ConfirmView):
|
||||
extra_context = {
|
||||
'title': _('Empty trash?')
|
||||
|
||||
Reference in New Issue
Block a user