Explicit document type needes to trigger indexing of documents, previously indexes with no document type associated would update for all document types

This commit is contained in:
Roberto Rosario
2015-01-07 03:39:11 -04:00
parent e75af75368
commit 5cdc95e99f
3 changed files with 5 additions and 5 deletions

View File

@@ -45,6 +45,8 @@ What's new in Mayan EDMS v1.1
* Watch folders * Watch folders
* Removal of the duplicate document search support * Removal of the duplicate document search support
* Removal of filesystem document indexes mirroring * Removal of filesystem document indexes mirroring
* New home view
* Explicit document types needed per index
Upgrading from a previous version Upgrading from a previous version

View File

@@ -25,9 +25,8 @@ def index_document(document):
delete_empty_index_nodes() delete_empty_index_nodes()
# Only update indexes where the document type is found or that do not have any document type specified # Only update indexes where the document type is found
# TODO: explicit document type selection, none != all for index in Index.objects.filter(enabled=True, document_types=document.document_type):
for index in Index.objects.filter(Q(enabled=True) & (Q(document_types=None) | Q(document_types=document.document_type))):
root_instance, created = IndexInstanceNode.objects.get_or_create(index_template_node=index.template_root, parent=None) root_instance, created = IndexInstanceNode.objects.get_or_create(index_template_node=index.template_root, parent=None)
for template_node in index.template_root.get_children(): for template_node in index.template_root.get_children():
index_warnings = cascade_eval(document, template_node, root_instance) index_warnings = cascade_eval(document, template_node, root_instance)

View File

@@ -44,8 +44,7 @@ class Index(models.Model):
IndexTemplateNode.objects.get_or_create(parent=None, index=self) IndexTemplateNode.objects.get_or_create(parent=None, index=self)
def get_document_types_names(self): def get_document_types_names(self):
# TODO: explicit document type selection, none != all return u', '.join([unicode(document_type) for document_type in self.document_types.all()] or [u'None'])
return u', '.join([unicode(document_type) for document_type in self.document_types.all()] or [u'All'])
def natural_key(self): def natural_key(self):
return (self.name,) return (self.name,)