We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
User account deletion doesn't remove resources from SOLR index
**Description of the bug**
Deleting a user in mezzanine also cascades to delete the user's resources. However it looks like the resources are not removed from the SOLR index. They still show up in discover.

Steps to reproduce the bug:
1. make a new user account
2. add a resource and make it discoverable
3. login as admin user and delete the account that you created in step 1 (via the mezzanine admin panel)
4. See that the resource listing persists on the Discover search page

**Expected behavior**
User account deletion should remove the user's resources from the SOLR index

**Additional information**
HS v 2.9.2


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `hs_core/hydro_realtime_signal_processor.py`
Content:
```
1 import logging
2 
3 from django.conf import settings
4 from django.db import models
5 from hs_core.models import Date, BaseResource
6 from hs_access_control.models import ResourceAccess
7 from haystack.exceptions import NotHandled
8 from haystack.signals import BaseSignalProcessor
9 
10 logger = logging.getLogger(__name__)
11 
12 
13 class HydroRealtimeSignalProcessor(BaseSignalProcessor):
14     """
15     Notes:
16     1. We assume everytime metadata is updated the modified datetime is updated
17     2. ResourceAccess does not update the modified datetime (it is not scientific metadata)
18     """
19 
20     def setup(self):
21         if not getattr(settings, "DISABLE_HAYSTACK", False):
22             models.signals.post_save.connect(self.handle_update, sender=Date)
23             models.signals.post_save.connect(self.handle_access, sender=ResourceAccess)
24 
25     def teardown(self):
26         if not getattr(settings, "DISABLE_HAYSTACK", False):
27             models.signals.post_save.disconnect(self.handle_update, sender=Date)
28             models.signals.post_save.disconnect(self.handle_access, sender=ResourceAccess)
29 
30     def handle_update(self, sender, instance, **kwargs):
31         try:
32             # resolve the BaseResource corresponding to the metadata element.
33             newbase = instance.metadata.resource
34             index_resource(self, newbase)
35         except Exception as e:
36             logger.exception("{} exception: {}".format(type(instance), str(e)))
37 
38     def handle_access(self, sender, instance, **kwargs):
39         try:
40             newbase = instance.resource
41             index_resource(self, newbase)
42         except Exception as e:
43             logger.exception("{} exception: {}".format(type(instance), str(e)))
44 
45 
46 def index_resource(signal_processor, instance: BaseResource):
47     if hasattr(instance, 'raccess') and hasattr(instance, 'metadata'):
48         # work around for failure of super(BaseResource, instance) to work properly.
49         # this always succeeds because this is a post-save object action.
50         newbase = BaseResource.objects.get(pk=instance.pk)
51         newsender = BaseResource
52         using_backends = signal_processor.connection_router.for_write(instance=newbase)
53         for using in using_backends:
54             # if object is public/discoverable or becoming public/discoverable, index it
55             # test whether the object should be exposed.
56             if instance.show_in_discover:
57                 try:
58                     index = signal_processor.connections[using].get_unified_index().get_index(newsender)
59                     index.update_object(newbase, using=using)
60                 except NotHandled:
61                     logger.exception("Failure: changes to %s with short_id %s not added to Solr Index.",
62                                      str(type(instance)), newbase.short_id)
63 
64             # if object is private or becoming private, delete from index
65             else:  # not to be shown in discover
66                 try:
67                     index = signal_processor.connections[using].get_unified_index().get_index(newsender)
68                     index.remove_object(newbase, using=using)
69                 except NotHandled:
70                     logger.exception("Failure: delete of %s with short_id %s failed.",
71                                      str(type(instance)), newbase.short_id)
72
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/hs_core/hydro_realtime_signal_processor.py b/hs_core/hydro_realtime_signal_processor.py
--- a/hs_core/hydro_realtime_signal_processor.py
+++ b/hs_core/hydro_realtime_signal_processor.py
@@ -21,11 +21,13 @@
         if not getattr(settings, "DISABLE_HAYSTACK", False):
             models.signals.post_save.connect(self.handle_update, sender=Date)
             models.signals.post_save.connect(self.handle_access, sender=ResourceAccess)
+            models.signals.post_delete.connect(self.handle_delete, sender=BaseResource)
 
     def teardown(self):
         if not getattr(settings, "DISABLE_HAYSTACK", False):
             models.signals.post_save.disconnect(self.handle_update, sender=Date)
             models.signals.post_save.disconnect(self.handle_access, sender=ResourceAccess)
+            models.signals.post_delete.disconnect(self.handle_delete, sender=BaseResource)
 
     def handle_update(self, sender, instance, **kwargs):
         try:

{"golden_diff": "diff --git a/hs_core/hydro_realtime_signal_processor.py b/hs_core/hydro_realtime_signal_processor.py\n--- a/hs_core/hydro_realtime_signal_processor.py\n+++ b/hs_core/hydro_realtime_signal_processor.py\n@@ -21,11 +21,13 @@\n         if not getattr(settings, \"DISABLE_HAYSTACK\", False):\n             models.signals.post_save.connect(self.handle_update, sender=Date)\n             models.signals.post_save.connect(self.handle_access, sender=ResourceAccess)\n+            models.signals.post_delete.connect(self.handle_delete, sender=BaseResource)\n \n     def teardown(self):\n         if not getattr(settings, \"DISABLE_HAYSTACK\", False):\n             models.signals.post_save.disconnect(self.handle_update, sender=Date)\n             models.signals.post_save.disconnect(self.handle_access, sender=ResourceAccess)\n+            models.signals.post_delete.disconnect(self.handle_delete, sender=BaseResource)\n \n     def handle_update(self, sender, instance, **kwargs):\n         try:\n", "issue": "User account deletion doesn't remove resources from SOLR index\n**Description of the bug**\r\nDeleting a user in mezzanine also cascades to delete the user's resources. However it looks like the resources are not removed from the SOLR index. They still show up in discover.\r\n\r\nSteps to reproduce the bug:\r\n1. make a new user account\r\n2. add a resource and make it discoverable\r\n3. login as admin user and delete the account that you created in step 1 (via the mezzanine admin panel)\r\n4. See that the resource listing persists on the Discover search page\r\n\r\n**Expected behavior**\r\nUser account deletion should remove the user's resources from the SOLR index\r\n\r\n**Additional information**\r\nHS v 2.9.2\r\n\n", "before_files": [{"content": "import logging\n\nfrom django.conf import settings\nfrom django.db import models\nfrom hs_core.models import Date, BaseResource\nfrom hs_access_control.models import ResourceAccess\nfrom haystack.exceptions import NotHandled\nfrom haystack.signals import BaseSignalProcessor\n\nlogger = logging.getLogger(__name__)\n\n\nclass HydroRealtimeSignalProcessor(BaseSignalProcessor):\n    \"\"\"\n    Notes:\n    1. We assume everytime metadata is updated the modified datetime is updated\n    2. ResourceAccess does not update the modified datetime (it is not scientific metadata)\n    \"\"\"\n\n    def setup(self):\n        if not getattr(settings, \"DISABLE_HAYSTACK\", False):\n            models.signals.post_save.connect(self.handle_update, sender=Date)\n            models.signals.post_save.connect(self.handle_access, sender=ResourceAccess)\n\n    def teardown(self):\n        if not getattr(settings, \"DISABLE_HAYSTACK\", False):\n            models.signals.post_save.disconnect(self.handle_update, sender=Date)\n            models.signals.post_save.disconnect(self.handle_access, sender=ResourceAccess)\n\n    def handle_update(self, sender, instance, **kwargs):\n        try:\n            # resolve the BaseResource corresponding to the metadata element.\n            newbase = instance.metadata.resource\n            index_resource(self, newbase)\n        except Exception as e:\n            logger.exception(\"{} exception: {}\".format(type(instance), str(e)))\n\n    def handle_access(self, sender, instance, **kwargs):\n        try:\n            newbase = instance.resource\n            index_resource(self, newbase)\n        except Exception as e:\n            logger.exception(\"{} exception: {}\".format(type(instance), str(e)))\n\n\ndef index_resource(signal_processor, instance: BaseResource):\n    if hasattr(instance, 'raccess') and hasattr(instance, 'metadata'):\n        # work around for failure of super(BaseResource, instance) to work properly.\n        # this always succeeds because this is a post-save object action.\n        newbase = BaseResource.objects.get(pk=instance.pk)\n        newsender = BaseResource\n        using_backends = signal_processor.connection_router.for_write(instance=newbase)\n        for using in using_backends:\n            # if object is public/discoverable or becoming public/discoverable, index it\n            # test whether the object should be exposed.\n            if instance.show_in_discover:\n                try:\n                    index = signal_processor.connections[using].get_unified_index().get_index(newsender)\n                    index.update_object(newbase, using=using)\n                except NotHandled:\n                    logger.exception(\"Failure: changes to %s with short_id %s not added to Solr Index.\",\n                                     str(type(instance)), newbase.short_id)\n\n            # if object is private or becoming private, delete from index\n            else:  # not to be shown in discover\n                try:\n                    index = signal_processor.connections[using].get_unified_index().get_index(newsender)\n                    index.remove_object(newbase, using=using)\n                except NotHandled:\n                    logger.exception(\"Failure: delete of %s with short_id %s failed.\",\n                                     str(type(instance)), newbase.short_id)\n", "path": "hs_core/hydro_realtime_signal_processor.py"}], "after_files": [{"content": "import logging\n\nfrom django.conf import settings\nfrom django.db import models\nfrom hs_core.models import Date, BaseResource\nfrom hs_access_control.models import ResourceAccess\nfrom haystack.exceptions import NotHandled\nfrom haystack.signals import BaseSignalProcessor\n\nlogger = logging.getLogger(__name__)\n\n\nclass HydroRealtimeSignalProcessor(BaseSignalProcessor):\n    \"\"\"\n    Notes:\n    1. We assume everytime metadata is updated the modified datetime is updated\n    2. ResourceAccess does not update the modified datetime (it is not scientific metadata)\n    \"\"\"\n\n    def setup(self):\n        if not getattr(settings, \"DISABLE_HAYSTACK\", False):\n            models.signals.post_save.connect(self.handle_update, sender=Date)\n            models.signals.post_save.connect(self.handle_access, sender=ResourceAccess)\n            models.signals.post_delete.connect(self.handle_delete, sender=BaseResource)\n\n    def teardown(self):\n        if not getattr(settings, \"DISABLE_HAYSTACK\", False):\n            models.signals.post_save.disconnect(self.handle_update, sender=Date)\n            models.signals.post_save.disconnect(self.handle_access, sender=ResourceAccess)\n            models.signals.post_delete.disconnect(self.handle_delete, sender=BaseResource)\n\n    def handle_update(self, sender, instance, **kwargs):\n        try:\n            # resolve the BaseResource corresponding to the metadata element.\n            newbase = instance.metadata.resource\n            index_resource(self, newbase)\n        except Exception as e:\n            logger.exception(\"{} exception: {}\".format(type(instance), str(e)))\n\n    def handle_access(self, sender, instance, **kwargs):\n        try:\n            newbase = instance.resource\n            index_resource(self, newbase)\n        except Exception as e:\n            logger.exception(\"{} exception: {}\".format(type(instance), str(e)))\n\n\ndef index_resource(signal_processor, instance: BaseResource):\n    if hasattr(instance, 'raccess') and hasattr(instance, 'metadata'):\n        # work around for failure of super(BaseResource, instance) to work properly.\n        # this always succeeds because this is a post-save object action.\n        newbase = BaseResource.objects.get(pk=instance.pk)\n        newsender = BaseResource\n        using_backends = signal_processor.connection_router.for_write(instance=newbase)\n        for using in using_backends:\n            # if object is public/discoverable or becoming public/discoverable, index it\n            # test whether the object should be exposed.\n            if instance.show_in_discover:\n                try:\n                    index = signal_processor.connections[using].get_unified_index().get_index(newsender)\n                    index.update_object(newbase, using=using)\n                except NotHandled:\n                    logger.exception(\"Failure: changes to %s with short_id %s not added to Solr Index.\",\n                                     str(type(instance)), newbase.short_id)\n\n            # if object is private or becoming private, delete from index\n            else:  # not to be shown in discover\n                try:\n                    index = signal_processor.connections[using].get_unified_index().get_index(newsender)\n                    index.remove_object(newbase, using=using)\n                except NotHandled:\n                    logger.exception(\"Failure: delete of %s with short_id %s failed.\",\n                                     str(type(instance)), newbase.short_id)\n", "path": "hs_core/hydro_realtime_signal_processor.py"}]}