From 3e300ac1e38120b07d5bf0451b4871b26bdcc6b4 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Wed, 20 Mar 2019 22:26:00 +0100
Subject: [PATCH] Try with binding

---
 SciPost_v1/signalprocessors.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/SciPost_v1/signalprocessors.py b/SciPost_v1/signalprocessors.py
index 2ca6ef790..92a1e5c14 100644
--- a/SciPost_v1/signalprocessors.py
+++ b/SciPost_v1/signalprocessors.py
@@ -12,8 +12,8 @@ from notifications.models import Notification
 from submissions.models import Submission
 
 
-@app.task(name='signalprocessors.remove_object_indexes')
-def remove_objects_indexes(sender_type_id, object_type_id, object_id):
+@app.task(bind=True, name='signalprocessors.remove_object_indexes')
+def remove_objects_indexes(self, sender_type_id, object_type_id, object_id):
     """
     Given a set of `objects` model instances, remove them from the index as preparation
     for the new index.
@@ -49,8 +49,8 @@ def remove_objects_indexes(sender_type_id, object_type_id, object_id):
                 pass
 
 
-@app.task(name='signalprocessors.update_instance_indexes')
-def update_instance_indexes(sender_type_id, object_type_id, object_id):
+@app.task(bind=True, name='signalprocessors.update_instance_indexes')
+def update_instance_indexes(self, sender_type_id, object_type_id, object_id):
     """
     Given an individual model instance, update its entire indexes.
     """
@@ -76,11 +76,10 @@ def update_instance_indexes(sender_type_id, object_type_id, object_id):
 class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor):
 
     def handle_save(self, sender, instance, **kwargs):
-        # if not isinstance(instance, Notification):
-        #     sender_type_id = ContentType.objects.get_for_model(sender).id
-        #     instance_type_id = ContentType.objects.get_for_model(instance).id
-        #     chain = (
-        #         remove_objects_indexes.s(sender_type_id, instance_type_id, instance.id)
-        #         | update_instance_indexes.s(sender_type_id, instance_type_id, instance.id))
-        #     chain()
-        pass
+        if not isinstance(instance, Notification):
+            sender_type_id = ContentType.objects.get_for_model(sender).id
+            instance_type_id = ContentType.objects.get_for_model(instance).id
+            chain = (
+                remove_objects_indexes.s(sender_type_id, instance_type_id, instance.id)
+                | update_instance_indexes.s(sender_type_id, instance_type_id, instance.id))
+            chain()
-- 
GitLab