Added method to link a model with it's column list to display on the generic list template, this way the same column layout is displayed regarless of the view that generates it.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import tempfile
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from common.api import register_links, register_menu
|
||||
from common.api import register_links, register_menu, register_model_list_columns
|
||||
from common.utils import pretty_size
|
||||
|
||||
from models import Document
|
||||
from staging import StagingFile
|
||||
@@ -23,12 +25,21 @@ document_download = {'text':_('download'), 'view':'document_download', 'args':'o
|
||||
|
||||
staging_file_preview = {'text':_('preview'), 'class':'fancybox', 'view':'staging_file_preview', 'args':'object.id', 'famfam':'drive_magnify'}
|
||||
|
||||
register_links(Document, [document_edit, document_edit_metadata, document_delete, document_preview, document_download])
|
||||
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling, document_view], menu_name='sidebar')
|
||||
register_links(Document, [document_edit, document_edit_metadata, document_delete, document_download])
|
||||
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling, document_view, document_preview], menu_name='sidebar')
|
||||
register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar')
|
||||
|
||||
register_links(StagingFile, [staging_file_preview])
|
||||
|
||||
register_model_list_columns(Document, [
|
||||
{'name':_(u'mimetype'), 'attribute':'file_mimetype'},
|
||||
{'name':_(u'added'), 'attribute':lambda x: x.date_added.date()},
|
||||
{'name':_(u'file size'), 'attribute':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
|
||||
{'name':_(u'thumbnail'), 'attribute':
|
||||
lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_preview', args=[x.id]),
|
||||
reverse('document_thumbnail', args=[x.id]))
|
||||
},
|
||||
])
|
||||
|
||||
register_menu([
|
||||
{'text':_('documents'), 'view':'document_list', 'links':[
|
||||
|
||||
Reference in New Issue
Block a user