✨(backend) refactor indexation signals and fix circular import issues
Signed-off-by: Fabre Florian <ffabre@hybird.org>
This commit is contained in:
committed by
Quentin BEY
parent
24460ffc3a
commit
bf978b5376
@@ -20,9 +20,7 @@ from django.core.files.base import ContentFile
|
||||
from django.core.files.storage import default_storage
|
||||
from django.core.mail import send_mail
|
||||
from django.db import models, transaction
|
||||
from django.db.models import signals
|
||||
from django.db.models.functions import Left, Length
|
||||
from django.dispatch import receiver
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
@@ -41,7 +39,6 @@ from .choices import (
|
||||
RoleChoices,
|
||||
get_equivalent_link_definition,
|
||||
)
|
||||
from .tasks.find import trigger_document_indexer
|
||||
from .validators import sub_validator
|
||||
|
||||
logger = getLogger(__name__)
|
||||
@@ -955,16 +952,6 @@ class Document(MP_Node, BaseModel):
|
||||
)
|
||||
|
||||
|
||||
@receiver(signals.post_save, sender=Document)
|
||||
def document_post_save(sender, instance, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Asynchronous call to the document indexer at the end of the transaction.
|
||||
Note : Within the transaction we can have an empty content and a serialization
|
||||
error.
|
||||
"""
|
||||
trigger_document_indexer(instance, on_commit=True)
|
||||
|
||||
|
||||
class LinkTrace(BaseModel):
|
||||
"""
|
||||
Relation model to trace accesses to a document via a link by a logged-in user.
|
||||
@@ -1195,15 +1182,6 @@ class DocumentAccess(BaseAccess):
|
||||
}
|
||||
|
||||
|
||||
@receiver(signals.post_save, sender=DocumentAccess)
|
||||
def document_access_post_save(sender, instance, created, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Asynchronous call to the document indexer at the end of the transaction.
|
||||
"""
|
||||
if not created:
|
||||
trigger_document_indexer(instance.document, on_commit=True)
|
||||
|
||||
|
||||
class DocumentAskForAccess(BaseModel):
|
||||
"""Relation model to ask for access to a document."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user