Files
mayan-edms/mayan/apps/documents/handlers.py
Roberto Rosario 57e7722f59 Don't show documents with 0 duplicates in the duplicated document list.
Also clean up the duplicated document model after a document is deleted.
Fix queue name typo.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2018-04-02 01:45:30 -04:00

32 lines
935 B
Python

from __future__ import unicode_literals
from django.apps import apps
from .literals import DEFAULT_DOCUMENT_TYPE_LABEL
from .signals import post_initial_document_type
from .tasks import task_clean_empty_duplicate_lists, task_scan_duplicates_for
def create_default_document_type(sender, **kwargs):
DocumentType = apps.get_model(
app_label='documents', model_name='DocumentType'
)
if not DocumentType.objects.count():
document_type = DocumentType.objects.create(
label=DEFAULT_DOCUMENT_TYPE_LABEL
)
post_initial_document_type.send(
sender=DocumentType, instance=document_type
)
def handler_scan_duplicates_for(sender, instance, **kwargs):
task_scan_duplicates_for.apply_async(
kwargs={'document_id': instance.document.pk}
)
def handler_remove_empty_duplicates_lists(sender, **kwargs):
task_clean_empty_duplicate_lists.apply_async()