Add natural key support to the Index model.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-08-03 18:51:17 -04:00
parent 4dea5911da
commit f42e1a96b2
2 changed files with 5 additions and 2 deletions

View File

@@ -9,8 +9,8 @@ class DocumentIndexInstanceNodeManager(models.Manager):
class IndexManager(models.Manager): class IndexManager(models.Manager):
def get_by_natural_key(self, name): def get_by_natural_key(self, slug):
return self.get(name=name) return self.get(slug=slug)
def index_document(self, document): def index_document(self, document):
for index in self.filter(enabled=True, document_types=document.document_type): for index in self.filter(enabled=True, document_types=document.document_type):

View File

@@ -83,6 +83,9 @@ class Index(models.Model):
def instance_root(self): def instance_root(self):
return self.template_root.index_instance_nodes.get() return self.template_root.index_instance_nodes.get()
def natural_key(self):
return (self.slug,)
def rebuild(self): def rebuild(self):
""" """
Delete and reconstruct the index by deleting of all its instance nodes Delete and reconstruct the index by deleting of all its instance nodes