Commit 318c9ff9 authored by Skia's avatar Skia

Add trigger to update Whoosh index on User update

parent 494062fb
Pipeline #751 passed with stage
in 4 minutes and 16 seconds
from haystack import indexes
from django.db import models
from haystack import indexes, signals
from core.models import User
......@@ -15,3 +17,15 @@ class UserIndex(indexes.SearchIndex, indexes.Indexable):
def get_updated_field(self):
return "last_update"
class UserOnlySignalProcessor(signals.BaseSignalProcessor):
def setup(self):
# Listen only to the ``User`` model.
models.signals.post_save.connect(self.handle_save, sender=User)
models.signals.post_delete.connect(self.handle_delete, sender=User)
def teardown(self):
# Disconnect only for the ``User`` model.
models.signals.post_save.disconnect(self.handle_save, sender=User)
models.signals.post_delete.disconnect(self.handle_delete, sender=User)
......@@ -153,6 +153,8 @@ HAYSTACK_CONNECTIONS = {
HAYSTACK_SIGNAL_PROCESSOR = 'core.search_indexes.UserOnlySignalProcessor'
WSGI_APPLICATION = 'sith.wsgi.application'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment