Ensure that the automatic index is created after the default document type is created.

This commit is contained in:
Roberto Rosario
2016-05-17 05:02:57 -04:00
parent 0bebef5ba9
commit c97208f609
5 changed files with 36 additions and 20 deletions

View File

@@ -17,7 +17,7 @@ from common import (
from common.classes import Package
from common.signals import post_initial_setup
from common.widgets import two_state_template
from documents.signals import post_document_created
from documents.signals import post_document_created, post_initial_document_type
from mayan.celery import app
from navigation import SourceColumn
from rest_api.classes import APIEndPoint
@@ -56,6 +56,10 @@ class DocumentIndexingApp(MayanAppConfig):
app_label='documents', model_name='Document'
)
DocumentType = apps.get_model(
app_label='documents', model_name='DocumentType'
)
DocumentMetadata = apps.get_model(
app_label='metadata', model_name='DocumentMetadata'
)
@@ -234,9 +238,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
document_created_index_update,
dispatch_uid='document_created_index_update', sender=Document
)
post_initial_setup.connect(
post_initial_document_type.connect(
create_default_document_index,
dispatch_uid='create_default_document_index'
dispatch_uid='create_default_document_index', sender=DocumentType
)
post_save.connect(
document_metadata_index_update,

View File

@@ -3,6 +3,8 @@ from __future__ import unicode_literals
from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from documents.literals import DEFAULT_DOCUMENT_TYPE_LABEL
from .tasks import task_delete_empty_index_nodes, task_index_document
@@ -14,7 +16,6 @@ def create_default_document_index(sender, **kwargs):
app_label='document_indexing', model_name='Index'
)
if not Index.objects.count():
index = Index.objects.create(
label=_('Creation date'), slug='creation_date'
)
@@ -32,7 +33,6 @@ def create_default_document_index(sender, **kwargs):
)
def document_created_index_update(sender, **kwargs):
task_index_document.apply_async(
kwargs=dict(document_id=kwargs['instance'].pk)

View File

@@ -3,6 +3,9 @@ from __future__ import unicode_literals
from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from .literals import DEFAULT_DOCUMENT_TYPE_LABEL
from .signals import post_initial_document_type
def create_default_document_type(sender, **kwargs):
DocumentType = apps.get_model(
@@ -10,4 +13,9 @@ def create_default_document_type(sender, **kwargs):
)
if not DocumentType.objects.count():
DocumentType.objects.create(label=_('Default'))
document_type = DocumentType.objects.create(
label=DEFAULT_DOCUMENT_TYPE_LABEL
)
post_initial_document_type.send(
sender=DocumentType, instance=document_type
)

View File

@@ -11,6 +11,7 @@ DELETE_STALE_STUBS_INTERVAL = 60 * 10 # 10 minutes
DEFAULT_DELETE_PERIOD = 30
DEFAULT_DELETE_TIME_UNIT = TIME_DELTA_UNIT_DAYS
DEFAULT_ZIP_FILENAME = 'document_bundle.zip'
DEFAULT_DOCUMENT_TYPE_LABEL = _('Default')
DOCUMENT_IMAGE_TASK_TIMEOUT = 20
STUB_EXPIRATION_INTERVAL = 60 * 60 * 24 # 24 hours
UPDATE_PAGE_COUNT_RETRY_DELAY = 10

View File

@@ -7,3 +7,6 @@ post_document_type_change = Signal(
providing_args=('instance',), use_caching=True
)
post_document_created = Signal(providing_args=('instance',), use_caching=True)
post_initial_document_type = Signal(
providing_args=('instance',), use_caching=True
)