diff --git a/apps/documents/__init__.py b/apps/documents/__init__.py index bdd067794c..b8d0bc6fcd 100755 --- a/apps/documents/__init__.py +++ b/apps/documents/__init__.py @@ -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: '' % (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, + # }) diff --git a/apps/documents/models.py b/apps/documents/models.py index 0cf858fd69..8182eaaf64 100755 --- a/apps/documents/models.py +++ b/apps/documents/models.py @@ -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') diff --git a/apps/dynamic_search/conf/__init__.py b/apps/dynamic_search/conf/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/dynamic_search/conf/settings.py b/apps/dynamic_search/conf/settings.py new file mode 100644 index 0000000000..78d8e8d199 --- /dev/null +++ b/apps/dynamic_search/conf/settings.py @@ -0,0 +1,3 @@ +from django.conf import settings + +SHOW_OBJECT_TYPE = getattr(settings, 'SEARCH_SHOW_OBJECT_TYPE', True) diff --git a/apps/dynamic_search/views.py b/apps/dynamic_search/views.py index f80d79080c..33d42e121f 100755 --- a/apps/dynamic_search/views.py +++ b/apps/dynamic_search/views.py @@ -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)) diff --git a/docs/TODO b/docs/TODO index 7f5ca2ac7c..f606e76d84 100755 --- a/docs/TODO +++ b/docs/TODO @@ -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 diff --git a/settings.py b/settings.py index 167e6c41e5..10c9ace59f 100755 --- a/settings.py +++ b/settings.py @@ -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: