Add sortable columns to all apps
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -240,6 +240,10 @@ class DocumentsApp(MayanAppConfig):
|
||||
document_page_thumbnail_widget = DocumentPageThumbnailWidget()
|
||||
|
||||
# Document
|
||||
SourceColumn(
|
||||
attribute='label', is_object_absolute_url=True, is_identifier=True,
|
||||
is_sortable=True, source=Document
|
||||
)
|
||||
SourceColumn(
|
||||
source=Document, label=_('Thumbnail'),
|
||||
func=lambda context: document_page_thumbnail_widget.render(
|
||||
@@ -247,7 +251,7 @@ class DocumentsApp(MayanAppConfig):
|
||||
)
|
||||
)
|
||||
SourceColumn(
|
||||
source=Document, attribute='document_type'
|
||||
attribute='document_type', is_sortable=True, source=Document,
|
||||
)
|
||||
SourceColumn(
|
||||
source=Document, label=_('Pages'),
|
||||
@@ -255,6 +259,16 @@ class DocumentsApp(MayanAppConfig):
|
||||
document=context['object']
|
||||
)
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='date_added', include_label=True, is_sortable=True,
|
||||
source=Document, views=('documents:document_list_recent_added',)
|
||||
)
|
||||
SourceColumn(
|
||||
func=lambda context: DuplicatedDocument.objects.get(
|
||||
document=context['object']
|
||||
).documents.count(), include_label=True, label=_('Duplicates'),
|
||||
source=Document, views=('documents:duplicated_document_list',)
|
||||
)
|
||||
|
||||
# DocumentPage
|
||||
SourceColumn(
|
||||
@@ -277,6 +291,11 @@ class DocumentsApp(MayanAppConfig):
|
||||
)
|
||||
|
||||
# DocumentType
|
||||
SourceColumn(
|
||||
attribute='label', is_identifier=True, is_sortable=True,
|
||||
source=DocumentType
|
||||
)
|
||||
|
||||
SourceColumn(
|
||||
source=DocumentType, label=_('Documents'),
|
||||
func=lambda context: context['object'].get_document_count(
|
||||
@@ -285,20 +304,27 @@ class DocumentsApp(MayanAppConfig):
|
||||
)
|
||||
|
||||
SourceColumn(
|
||||
attribute='enabled', label=_('Enabled'),
|
||||
source=DocumentTypeFilename, widget=TwoStateWidget
|
||||
attribute='filename', is_identifier=True, is_sortable=True,
|
||||
source=DocumentTypeFilename
|
||||
)
|
||||
SourceColumn(
|
||||
attribute='enabled', is_sortable=True, source=DocumentTypeFilename,
|
||||
widget=TwoStateWidget
|
||||
)
|
||||
|
||||
# DeletedDocument
|
||||
SourceColumn(
|
||||
attribute='label', is_identifier=True, is_sortable=True,
|
||||
source=DeletedDocument
|
||||
)
|
||||
SourceColumn(
|
||||
source=DeletedDocument, label=_('Thumbnail'),
|
||||
func=lambda context: document_page_thumbnail_widget.render(
|
||||
instance=context['object']
|
||||
)
|
||||
)
|
||||
|
||||
SourceColumn(
|
||||
source=DeletedDocument, attribute='document_type'
|
||||
attribute='document_type', is_sortable=True, source=DeletedDocument
|
||||
)
|
||||
SourceColumn(
|
||||
source=DeletedDocument, attribute='deleted_date_time'
|
||||
@@ -307,7 +333,7 @@ class DocumentsApp(MayanAppConfig):
|
||||
# DocumentVersion
|
||||
SourceColumn(
|
||||
source=DocumentVersion, attribute='timestamp', is_identifier=True,
|
||||
is_absolute_url=True
|
||||
is_object_absolute_url=True
|
||||
)
|
||||
SourceColumn(
|
||||
source=DocumentVersion, label=_('Thumbnail'),
|
||||
@@ -322,25 +348,13 @@ class DocumentsApp(MayanAppConfig):
|
||||
)
|
||||
)
|
||||
SourceColumn(
|
||||
source=DocumentVersion, attribute='mimetype'
|
||||
attribute='mimetype', is_sortable=True, source=DocumentVersion
|
||||
)
|
||||
SourceColumn(
|
||||
source=DocumentVersion, attribute='encoding'
|
||||
attribute='encoding', is_sortable=True, source=DocumentVersion
|
||||
)
|
||||
SourceColumn(
|
||||
source=DocumentVersion, attribute='comment'
|
||||
)
|
||||
|
||||
# DuplicatedDocument
|
||||
SourceColumn(
|
||||
source=DuplicatedDocument, label=_('Thumbnail'),
|
||||
func=lambda context: document_page_thumbnail_widget.render(
|
||||
instance=context['object'].document
|
||||
)
|
||||
)
|
||||
SourceColumn(
|
||||
source=DuplicatedDocument, label=_('Duplicates'),
|
||||
func=lambda context: context['object'].documents.count()
|
||||
attribute='comment', is_sortable=True, source=DocumentVersion
|
||||
)
|
||||
|
||||
Template(
|
||||
|
||||
@@ -383,25 +383,33 @@ link_document_type_edit = Link(
|
||||
view='documents:document_type_edit',
|
||||
)
|
||||
link_document_type_filename_create = Link(
|
||||
args='document_type.id', icon_class=icon_document_type_filename_create,
|
||||
args='document_type.id',
|
||||
icon_class_path='mayan.apps.documents.icons.icon_document_type_filename_create',
|
||||
permissions=(permission_document_type_edit,),
|
||||
text=_('Add quick label to document type'),
|
||||
view='documents:document_type_filename_create',
|
||||
)
|
||||
link_document_type_filename_delete = Link(
|
||||
args='resolved_object.id', permissions=(permission_document_type_edit,),
|
||||
args='resolved_object.id',
|
||||
icon_class_path='mayan.apps.documents.icons.icon_document_type_filename_delete',
|
||||
permissions=(permission_document_type_edit,),
|
||||
tags='dangerous', text=_('Delete'),
|
||||
view='documents:document_type_filename_delete',
|
||||
)
|
||||
link_document_type_filename_edit = Link(
|
||||
args='resolved_object.id', permissions=(permission_document_type_edit,),
|
||||
args='resolved_object.id',
|
||||
icon_class_path='mayan.apps.documents.icons.icon_document_type_filename_edit',
|
||||
permissions=(permission_document_type_edit,),
|
||||
text=_('Edit'), view='documents:document_type_filename_edit',
|
||||
)
|
||||
link_document_type_filename_list = Link(
|
||||
args='resolved_object.id', permissions=(permission_document_type_view,),
|
||||
args='resolved_object.id',
|
||||
icon_class_path='mayan.apps.documents.icons.icon_document_type_filename_list',
|
||||
permissions=(permission_document_type_view,),
|
||||
text=_('Quick labels'), view='documents:document_type_filename_list',
|
||||
)
|
||||
link_document_type_list = Link(
|
||||
icon_class_path='mayan.apps.documents.icons.icon_document_type_list',
|
||||
permissions=(permission_document_type_view,), text=_('Document types'),
|
||||
view='documents:document_type_list'
|
||||
)
|
||||
|
||||
@@ -62,6 +62,7 @@ class DocumentTypeListView(SingleObjectListView):
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'no_results_icon': icon_document_type_setup,
|
||||
'no_results_main_link': link_document_type_create.resolve(
|
||||
context=RequestContext(request=self.request)
|
||||
@@ -225,6 +226,7 @@ class DocumentTypeFilenameListView(SingleObjectListView):
|
||||
return {
|
||||
'document_type': self.get_document_type(),
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'navigation_object_list': ('document_type',),
|
||||
'no_results_icon': icon_document_type_filename,
|
||||
'no_results_main_link': link_document_type_filename_create.resolve(
|
||||
|
||||
@@ -84,6 +84,7 @@ class DocumentListView(SingleObjectListView):
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_links': True,
|
||||
'hide_object': True,
|
||||
'list_as_items': True,
|
||||
'no_results_icon': icon_document_list,
|
||||
'no_results_text': _(
|
||||
@@ -669,16 +670,16 @@ class DuplicatedDocumentListView(DocumentListView):
|
||||
context = super(DuplicatedDocumentListView, self).get_extra_context()
|
||||
context.update(
|
||||
{
|
||||
'extra_columns': (
|
||||
{
|
||||
'name': _('Duplicates'),
|
||||
'attribute': encapsulate(
|
||||
lambda document: DuplicatedDocument.objects.get(
|
||||
document=document
|
||||
).documents.count()
|
||||
)
|
||||
},
|
||||
),
|
||||
#'extra_columns': (
|
||||
# {
|
||||
# 'name': _('Duplicates'),
|
||||
# 'attribute': encapsulate(
|
||||
# lambda document: DuplicatedDocument.objects.get(
|
||||
# document=document
|
||||
# ).documents.count()
|
||||
# )
|
||||
# },
|
||||
#),
|
||||
'no_results_icon': icon_duplicated_document_list,
|
||||
'no_results_text': _(
|
||||
'Duplicates are documents that are composed of the exact '
|
||||
|
||||
Reference in New Issue
Block a user