prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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
  
  
  </issue>
  <code>
  [start of hs_core/hydro_realtime_signal_processor.py]
  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 of hs_core/hydro_realtime_signal_processor.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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:
  
verification_info: {"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"}]}