Update documents app to use the new SearchModel class
This commit is contained in:
@@ -13,6 +13,7 @@ from history.api import register_history_type
|
||||
from history.permissions import PERMISSION_HISTORY_VIEW
|
||||
from project_setup.api import register_setup
|
||||
from acls.api import class_permissions
|
||||
from dynamic_search.classes import SearchModel
|
||||
|
||||
from .models import (Document, DocumentPage,
|
||||
DocumentPageTransformation, DocumentType, DocumentTypeFilename,
|
||||
@@ -203,3 +204,14 @@ class_permissions(Document, [
|
||||
PERMISSION_DOCUMENT_VERSION_REVERT,
|
||||
PERMISSION_HISTORY_VIEW
|
||||
])
|
||||
|
||||
document_search = SearchModel('documents', 'Document')
|
||||
document_search.add_model_field('document_type__name', label=_(u'Document type'))
|
||||
document_search.add_model_field('documentversion__mimetype', label=_(u'MIME type'))
|
||||
document_search.add_model_field('documentversion__filename', label=_(u'Filename'))
|
||||
document_search.add_model_field('documentmetadata__metadata_type__name', label=_(u'Metadata type'))
|
||||
document_search.add_model_field('documentmetadata__value', label=_(u'Metadata value'))
|
||||
document_search.add_model_field('documentversion__documentpage__content', label=_(u'Content'))
|
||||
document_search.add_model_field('description', label=_(u'Description'))
|
||||
document_search.add_model_field('tags__name', label=_(u'Tags'))
|
||||
document_search.add_related_field('comments', 'Comment', 'comment', 'object_pk', label=_(u'Comments'))
|
||||
|
||||
@@ -19,7 +19,6 @@ from django.utils.translation import ugettext
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from dynamic_search.api import register
|
||||
from converter.api import get_page_count
|
||||
from converter.api import get_available_transformations_choices
|
||||
from converter.api import convert
|
||||
@@ -655,19 +654,3 @@ class RecentDocument(models.Model):
|
||||
ordering = ('-datetime_accessed',)
|
||||
verbose_name = _(u'recent document')
|
||||
verbose_name_plural = _(u'recent documents')
|
||||
|
||||
|
||||
# Register the fields that will be searchable
|
||||
register('document', Document, _(u'document'), [
|
||||
{'name': u'document_type__name', 'title': _(u'Document type')},
|
||||
{'name': u'documentversion__mimetype', 'title': _(u'MIME type')},
|
||||
{'name': u'documentversion__filename', 'title': _(u'Filename')},
|
||||
{'name': u'documentmetadata__metadata_type__name', 'title': _(u'Metadata type')},
|
||||
{'name': u'documentmetadata__value', 'title': _(u'Metadata value')},
|
||||
{'name': u'documentversion__documentpage__content', 'title': _(u'Content')},
|
||||
{'name': u'description', 'title': _(u'Description')},
|
||||
{'name': u'tags__name', 'title': _(u'Tags')},
|
||||
{'name': u'comments__comment', 'title': _(u'Comments')},
|
||||
]
|
||||
)
|
||||
#register(Document, _(u'document'), ['document_type__name', 'file_mimetype', 'documentmetadata__value', 'documentpage__content', 'description', {'field_name':'file_filename', 'comparison':'iexact'}])
|
||||
|
||||
Reference in New Issue
Block a user