Show only document metadata in document list view
This commit is contained in:
@@ -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'}
|
||||
|
||||
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_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'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]))
|
||||
},
|
||||
{'name':_(u'metadata'), 'attribute':
|
||||
lambda x: ', '.join(['%s - %s' %(metadata.metadata_type, metadata.value) for metadata in x.documentmetadata_set.all()])
|
||||
},
|
||||
|
||||
])
|
||||
|
||||
register_menu([
|
||||
@@ -47,3 +51,10 @@ register_menu([
|
||||
],'famfam':'page','position':4}])
|
||||
|
||||
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,
|
||||
# })
|
||||
|
||||
@@ -230,8 +230,7 @@ class MetadataType(models.Model):
|
||||
#TODO: datatype?
|
||||
|
||||
def __unicode__(self):
|
||||
#return '%s - %s' % (self.name, self.title if self.title else self.name)
|
||||
return self.name
|
||||
return self.title if self.title else self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'metadata type')
|
||||
|
||||
0
apps/dynamic_search/conf/__init__.py
Normal file
0
apps/dynamic_search/conf/__init__.py
Normal file
3
apps/dynamic_search/conf/settings.py
Normal file
3
apps/dynamic_search/conf/settings.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.conf import settings
|
||||
|
||||
SHOW_OBJECT_TYPE = getattr(settings, 'SEARCH_SHOW_OBJECT_TYPE', True)
|
||||
@@ -7,6 +7,7 @@ from django.db.models import Q
|
||||
|
||||
from api import search_list
|
||||
from forms import SearchForm
|
||||
from conf.settings import SHOW_OBJECT_TYPE
|
||||
|
||||
#original code from:
|
||||
#http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/
|
||||
@@ -68,14 +69,19 @@ def search(request):
|
||||
object_list.append(result)
|
||||
else:
|
||||
form = SearchForm()
|
||||
|
||||
context = {
|
||||
'query_string':query_string,
|
||||
'found_entries':found_entries,
|
||||
'form':form,
|
||||
'object_list':object_list,
|
||||
'form_title':_(u'Search'),
|
||||
'title':_(u'results with: %s') % query_string
|
||||
}
|
||||
|
||||
return render_to_response('search_results.html', {
|
||||
'query_string':query_string,
|
||||
'found_entries':found_entries,
|
||||
'form':form,
|
||||
'object_list':object_list,
|
||||
'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
|
||||
},
|
||||
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))
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* Show abbreviated uuid in document list - DEFERRED, Impractical
|
||||
* Update symlinks when document or metadata changed - DONE
|
||||
* Cache thumbnails and preview by document hash not by uuid - DONE
|
||||
* Show document metadata in document list - DONE
|
||||
* Document list filtering by metadata
|
||||
* Filterform date filtering widget
|
||||
* Validate GET data before saving file
|
||||
@@ -43,7 +44,6 @@
|
||||
* Roles
|
||||
* Workflows
|
||||
* Scheduled maintenance (cleanup, deferred OCR's)
|
||||
* Show document metadata in document list
|
||||
* Add tags to documents
|
||||
* Field for document language or autodetect
|
||||
* Recognize multi-page documents
|
||||
|
||||
@@ -202,6 +202,8 @@ LOGIN_EXEMPT_URLS = (
|
||||
#CONVERTER_CONVERT_PATH = u'/usr/bin/convert'
|
||||
#CONVERTER_OCR_OPTIONS = u'-colorspace Gray -depth 8 -resample 200x200'
|
||||
#OCR_TESSERACT_PATH = u'/usr/bin/tesseract'
|
||||
# Override
|
||||
SEARCH_SHOW_OBJECT_TYPE = False
|
||||
#======== End of configuration options =======
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user