2
2
from __future__ import absolute_import
3
3
import django .dispatch
4
4
from django .dispatch import receiver
5
+ from django_elasticsearch_dsl .apps import DEDConfig
5
6
from django_elasticsearch_dsl .registries import registry
6
7
7
8
from readthedocs .projects .models import HTMLFile
@@ -20,13 +21,17 @@ def index_html_file(instance_list, **_):
20
21
'app_label' : HTMLFile ._meta .app_label ,
21
22
'model_name' : HTMLFile .__name__ ,
22
23
'document_class' : str (PageDocument ),
23
- 'index_name' : None , # No neeed to change the index name
24
+ 'index_name' : None , # No need to change the index name
24
25
'objects_id' : [obj .id for obj in instance_list ],
25
26
}
26
27
27
- index_objects_to_es_task (** kwargs )
28
+ # Do not index if autosync is disabled globally
29
+ if DEDConfig .autosync_enabled ():
30
+ index_objects_to_es_task (** kwargs )
28
31
29
32
30
33
@receiver (bulk_post_delete , sender = HTMLFile )
31
34
def remove_html_file (instance_list , ** _ ):
32
- registry .delete (instance_list )
35
+ # Do not index if autosync is disabled globally
36
+ if DEDConfig .autosync_enabled ():
37
+ registry .delete (instance_list )
0 commit comments