Show only document metadata in document list view

This commit is contained in:
Roberto Rosario
2011-02-10 21:16:33 -04:00
parent 81308b1229
commit 350fdee9c9
7 changed files with 37 additions and 16 deletions
+15 -4
View File
@@ -25,20 +25,24 @@ 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'} 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_download]) register_links(Document, [document_edit, document_edit_metadata, document_delete, document_download], menu_name='sidebar')
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling, document_view], menu_name='sidebar') register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling, document_view], 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(['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_links(StagingFile, [staging_file_preview])
register_model_list_columns(Document, [ register_model_list_columns(Document, [
{'name':_(u'mimetype'), 'attribute':'file_mimetype'}, #{'name':_(u'mimetype'), 'attribute':'file_mimetype'},
{'name':_(u'added'), 'attribute':lambda x: x.date_added.date()}, #{'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'file size'), 'attribute':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},
{'name':_(u'thumbnail'), 'attribute': {'name':_(u'thumbnail'), 'attribute':
lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_preview', args=[x.id]), lambda x: '<a class="fancybox" href="%s"><img src="%s" /></a>' % (reverse('document_preview', args=[x.id]),
reverse('document_thumbnail', args=[x.id])) reverse('document_thumbnail', args=[x.id]))
}, },
{'name':_(u'metadata'), 'attribute':
lambda x: ', '.join(['%s - %s' %(metadata.metadata_type, metadata.value) for metadata in x.documentmetadata_set.all()])
},
]) ])
register_menu([ register_menu([
@@ -47,3 +51,10 @@ register_menu([
],'famfam':'page','position':4}]) ],'famfam':'page','position':4}])
TEMPORARY_DIRECTORY = documents_settings.TEMPORARY_DIRECTORY if documents_settings.TEMPORARY_DIRECTORY else tempfile.mkdtemp() TEMPORARY_DIRECTORY = documents_settings.TEMPORARY_DIRECTORY if documents_settings.TEMPORARY_DIRECTORY else tempfile.mkdtemp()
#','.join([metadata for metadata in document.documentmetadata_set.all()])
# initial.append({
# 'metadata_type':metadata.metadata_type,
# 'document_type':document.document_type,
# 'value':metadata.value,
# })
+1 -2
View File
@@ -230,8 +230,7 @@ class MetadataType(models.Model):
#TODO: datatype? #TODO: datatype?
def __unicode__(self): def __unicode__(self):
#return '%s - %s' % (self.name, self.title if self.title else self.name) return self.title if self.title else self.name
return self.name
class Meta: class Meta:
verbose_name = _(u'metadata type') verbose_name = _(u'metadata type')
+3
View File
@@ -0,0 +1,3 @@
from django.conf import settings
SHOW_OBJECT_TYPE = getattr(settings, 'SEARCH_SHOW_OBJECT_TYPE', True)
+15 -9
View File
@@ -7,6 +7,7 @@ from django.db.models import Q
from api import search_list from api import search_list
from forms import SearchForm from forms import SearchForm
from conf.settings import SHOW_OBJECT_TYPE
#original code from: #original code from:
#http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/ #http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/
@@ -69,13 +70,18 @@ def search(request):
else: else:
form = SearchForm() form = SearchForm()
return render_to_response('search_results.html', { context = {
'query_string':query_string, 'query_string':query_string,
'found_entries':found_entries, 'found_entries':found_entries,
'form':form, 'form':form,
'object_list':object_list, 'object_list':object_list,
'form_title':_(u'Search'), 'form_title':_(u'Search'),
'extra_columns':[{'name':_(u'type'), 'attribute':lambda x:x._meta.verbose_name[0].upper() + x._meta.verbose_name[1:]}], 'title':_(u'results with: %s') % query_string
'title':_(u'results with: %s') % query_string }
},
if SHOW_OBJECT_TYPE:
context.update({'extra_columns':
[{'name':_(u'type'), 'attribute':lambda x:x._meta.verbose_name[0].upper() + x._meta.verbose_name[1:]}]})
return render_to_response('search_results.html', context,
context_instance=RequestContext(request)) context_instance=RequestContext(request))
+1 -1
View File
@@ -21,6 +21,7 @@
* Show abbreviated uuid in document list - DEFERRED, Impractical * Show abbreviated uuid in document list - DEFERRED, Impractical
* Update symlinks when document or metadata changed - DONE * Update symlinks when document or metadata changed - DONE
* Cache thumbnails and preview by document hash not by uuid - DONE * Cache thumbnails and preview by document hash not by uuid - DONE
* Show document metadata in document list - DONE
* Document list filtering by metadata * Document list filtering by metadata
* Filterform date filtering widget * Filterform date filtering widget
* Validate GET data before saving file * Validate GET data before saving file
@@ -43,7 +44,6 @@
* Roles * Roles
* Workflows * Workflows
* Scheduled maintenance (cleanup, deferred OCR's) * Scheduled maintenance (cleanup, deferred OCR's)
* Show document metadata in document list
* Add tags to documents * Add tags to documents
* Field for document language or autodetect * Field for document language or autodetect
* Recognize multi-page documents * Recognize multi-page documents
+2
View File
@@ -202,6 +202,8 @@ LOGIN_EXEMPT_URLS = (
#CONVERTER_CONVERT_PATH = u'/usr/bin/convert' #CONVERTER_CONVERT_PATH = u'/usr/bin/convert'
#CONVERTER_OCR_OPTIONS = u'-colorspace Gray -depth 8 -resample 200x200' #CONVERTER_OCR_OPTIONS = u'-colorspace Gray -depth 8 -resample 200x200'
#OCR_TESSERACT_PATH = u'/usr/bin/tesseract' #OCR_TESSERACT_PATH = u'/usr/bin/tesseract'
# Override
SEARCH_SHOW_OBJECT_TYPE = False
#======== End of configuration options ======= #======== End of configuration options =======
try: try: