diff --git a/mayan/apps/document_indexing/api.py b/mayan/apps/document_indexing/api.py index c1bf3b5f0c..2d76bc0301 100644 --- a/mayan/apps/document_indexing/api.py +++ b/mayan/apps/document_indexing/api.py @@ -22,6 +22,7 @@ def update_indexes(document): warnings = [] # Only update indexes where the document type is found or that do not have any document type specified + # TODO: explicit document type selection, none != all 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) for template_node in index.template_root.get_children(): @@ -31,20 +32,6 @@ def update_indexes(document): return warnings -# Internal functions -def find_lowest_available_suffix(index_instance, document): - index_instance_documents = DocumentRenameCount.objects.filter(index_instance_node=index_instance) - files_list = [] - for index_instance_document in index_instance_documents: - files_list.append(assemble_suffixed_filename(index_instance_document.document.label, index_instance_document.suffix)) - - for suffix in xrange(MAX_SUFFIX_COUNT): - if assemble_suffixed_filename(document.label, suffix) not in files_list: - return suffix - - raise MaxSuffixCountReached(ugettext(u'Maximum suffix (%s) count reached.') % MAX_SUFFIX_COUNT) - - def cascade_eval(document, template_node, parent_index_instance=None): """ Evaluate an enabled index expression and update or create all the @@ -66,13 +53,6 @@ def cascade_eval(document, template_node, parent_index_instance=None): index_instance, created = IndexInstanceNode.objects.get_or_create(index_template_node=template_node, value=result, parent=parent_index_instance) if template_node.link_documents: - suffix = find_lowest_available_suffix(index_instance, document) - document_count = DocumentRenameCount( - index_instance_node=index_instance, - document=document, - suffix=suffix - ) - document_count.save() index_instance.documents.add(document) for child in template_node.get_children(): diff --git a/mayan/apps/document_indexing/models.py b/mayan/apps/document_indexing/models.py index 2e35f00b37..07ca68d257 100644 --- a/mayan/apps/document_indexing/models.py +++ b/mayan/apps/document_indexing/models.py @@ -13,6 +13,7 @@ from .managers import IndexManager class Index(models.Model): name = models.CharField(unique=True, max_length=64, verbose_name=_(u'Name'), help_text=_(u'Internal name used to reference this index.')) + # TODO: normalize 'title' to 'label' title = models.CharField(unique=True, max_length=128, verbose_name=_(u'Title'), help_text=_(u'The name that will be visible to users.')) enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'), help_text=_(u'Causes this index to be visible and updated when document data changes.')) document_types = models.ManyToManyField(DocumentType, verbose_name=_(u'Document types')) @@ -43,6 +44,7 @@ class Index(models.Model): IndexTemplateNode.objects.get_or_create(parent=None, index=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'All']) def natural_key(self):