Add support for updating indexing per document type
This commit is contained in:
@@ -6,7 +6,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from mptt.models import MPTTModel
|
||||
from mptt.fields import TreeForeignKey
|
||||
|
||||
from documents.models import Document
|
||||
from documents.models import Document, DocumentType
|
||||
|
||||
from .conf.settings import AVAILABLE_INDEXING_FUNCTIONS
|
||||
|
||||
@@ -17,6 +17,7 @@ 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.'))
|
||||
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'))
|
||||
|
||||
@property
|
||||
def template_root(self):
|
||||
@@ -33,6 +34,12 @@ class Index(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return ('index_instance_node_view', [self.instance_root.pk])
|
||||
|
||||
def get_index_document_types(self):
|
||||
return self.document_types.all()
|
||||
|
||||
def get_document_types_not_in_index(self):
|
||||
return DocumentType.objects.exclude(pk__in=self.get_index_document_types())
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(Index, self).save(*args, **kwargs)
|
||||
index_template_node_root, created = IndexTemplateNode.objects.get_or_create(parent=None, index=self)
|
||||
|
||||
Reference in New Issue
Block a user