prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Logger les suppressions de galleries et de publications
  Logger juste le fait que ce soit une suppression, le type d’objet concerné et le slug histoire qu’on puisse facilement remonter aux logs de nginx correspondantes avec la date et l’heures en cas de problème.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `zds/tutorialv2/receivers.py`
  Content:
  ```
  1 # coding: utf-8
  2 
  3 
  4 import datetime
  5 from django.dispatch.dispatcher import receiver
  6 from django.utils.translation import ugettext_lazy as _
  7 from zds.tutorialv2.models.models_database import PublishableContent
  8 from zds.tutorialv2.signals import content_unpublished
  9 from zds.utils import get_current_user
  10 from zds.utils.models import Alert
  11 
  12 
  13 @receiver(content_unpublished, sender=PublishableContent)
  14 def cleanup_validation_alerts(sender, instance, **kwargs):
  15     """
  16     When opinions are unpublished (probably permanently), we must be sure all alerts are handled. For now we just \
  17     resolve them.
  18 
  19     :param sender: sender class
  20     :param instance: object instance
  21     :param kwargs: possibily moderator
  22     """
  23     if instance.is_opinion:
  24         moderator = kwargs.get('moderator', get_current_user())
  25         Alert.objects.filter(scope='CONTENT', content=instance).update(moderator=moderator,
  26                                                                        resolve_reason=_('Le billet a été dépublié.'),
  27                                                                        solved_date=datetime.datetime.now(),
  28                                                                        solved=True)
  29
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/zds/tutorialv2/receivers.py b/zds/tutorialv2/receivers.py
  --- a/zds/tutorialv2/receivers.py
  +++ b/zds/tutorialv2/receivers.py
  @@ -2,10 +2,15 @@
   
   
   import datetime
  +import logging
  +
   from django.dispatch.dispatcher import receiver
   from django.utils.translation import ugettext_lazy as _
  +from django.db import models
  +
   from zds.tutorialv2.models.models_database import PublishableContent
   from zds.tutorialv2.signals import content_unpublished
  +from zds.gallery.models import Gallery
   from zds.utils import get_current_user
   from zds.utils.models import Alert
   
  @@ -26,3 +31,25 @@
                                                                          resolve_reason=_('Le billet a été dépublié.'),
                                                                          solved_date=datetime.datetime.now(),
                                                                          solved=True)
  +
  +
  +@receiver(models.signals.post_delete, sender=Gallery)
  +@receiver(models.signals.post_delete, sender=PublishableContent)
  +def log_content_deletion(sender, instance, **kwargs):
  +    """
  +    When a content or gallery is deleted, this action is logged.
  +    """
  +
  +    logger = logging.getLogger(__name__)
  +    current_user = get_current_user()
  +
  +    if current_user is None:
  +        logger.info('%(instance_model)s #%(instance_pk)d (%(instance_slug)s) has been deleted. User not found.',
  +                    {'instance_model': type(instance).__name__, 'instance_pk': instance.pk,
  +                     'instance_slug': instance.slug})
  +    else:
  +        logger.info('%(instance_model)s #%(instance_pk)d (%(instance_slug)s) has been deleted '
  +                    'by user #%(user_pk)d (%(username)s).', {'instance_model': type(instance).__name__,
  +                                                             'instance_pk': instance.pk, 'instance_slug': instance.slug,
  +                                                             'user_pk': current_user.pk,
  +                                                             'username': current_user.username})
  
verification_info: {"golden_diff": "diff --git a/zds/tutorialv2/receivers.py b/zds/tutorialv2/receivers.py\n--- a/zds/tutorialv2/receivers.py\n+++ b/zds/tutorialv2/receivers.py\n@@ -2,10 +2,15 @@\n \n \n import datetime\n+import logging\n+\n from django.dispatch.dispatcher import receiver\n from django.utils.translation import ugettext_lazy as _\n+from django.db import models\n+\n from zds.tutorialv2.models.models_database import PublishableContent\n from zds.tutorialv2.signals import content_unpublished\n+from zds.gallery.models import Gallery\n from zds.utils import get_current_user\n from zds.utils.models import Alert\n \n@@ -26,3 +31,25 @@\n                                                                        resolve_reason=_('Le billet a \u00e9t\u00e9 d\u00e9publi\u00e9.'),\n                                                                        solved_date=datetime.datetime.now(),\n                                                                        solved=True)\n+\n+\n+@receiver(models.signals.post_delete, sender=Gallery)\n+@receiver(models.signals.post_delete, sender=PublishableContent)\n+def log_content_deletion(sender, instance, **kwargs):\n+    \"\"\"\n+    When a content or gallery is deleted, this action is logged.\n+    \"\"\"\n+\n+    logger = logging.getLogger(__name__)\n+    current_user = get_current_user()\n+\n+    if current_user is None:\n+        logger.info('%(instance_model)s #%(instance_pk)d (%(instance_slug)s) has been deleted. User not found.',\n+                    {'instance_model': type(instance).__name__, 'instance_pk': instance.pk,\n+                     'instance_slug': instance.slug})\n+    else:\n+        logger.info('%(instance_model)s #%(instance_pk)d (%(instance_slug)s) has been deleted '\n+                    'by user #%(user_pk)d (%(username)s).', {'instance_model': type(instance).__name__,\n+                                                             'instance_pk': instance.pk, 'instance_slug': instance.slug,\n+                                                             'user_pk': current_user.pk,\n+                                                             'username': current_user.username})\n", "issue": "Logger les suppressions de galleries et de publications\nLogger juste le fait que ce soit une suppression, le type d\u2019objet concern\u00e9 et le slug histoire qu\u2019on puisse facilement remonter aux logs de nginx correspondantes avec la date et l\u2019heures en cas de probl\u00e8me.\n", "before_files": [{"content": "# coding: utf-8\n\n\nimport datetime\nfrom django.dispatch.dispatcher import receiver\nfrom django.utils.translation import ugettext_lazy as _\nfrom zds.tutorialv2.models.models_database import PublishableContent\nfrom zds.tutorialv2.signals import content_unpublished\nfrom zds.utils import get_current_user\nfrom zds.utils.models import Alert\n\n\n@receiver(content_unpublished, sender=PublishableContent)\ndef cleanup_validation_alerts(sender, instance, **kwargs):\n    \"\"\"\n    When opinions are unpublished (probably permanently), we must be sure all alerts are handled. For now we just \\\n    resolve them.\n\n    :param sender: sender class\n    :param instance: object instance\n    :param kwargs: possibily moderator\n    \"\"\"\n    if instance.is_opinion:\n        moderator = kwargs.get('moderator', get_current_user())\n        Alert.objects.filter(scope='CONTENT', content=instance).update(moderator=moderator,\n                                                                       resolve_reason=_('Le billet a \u00e9t\u00e9 d\u00e9publi\u00e9.'),\n                                                                       solved_date=datetime.datetime.now(),\n                                                                       solved=True)\n", "path": "zds/tutorialv2/receivers.py"}], "after_files": [{"content": "# coding: utf-8\n\n\nimport datetime\nimport logging\n\nfrom django.dispatch.dispatcher import receiver\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.db import models\n\nfrom zds.tutorialv2.models.models_database import PublishableContent\nfrom zds.tutorialv2.signals import content_unpublished\nfrom zds.gallery.models import Gallery\nfrom zds.utils import get_current_user\nfrom zds.utils.models import Alert\n\n\n@receiver(content_unpublished, sender=PublishableContent)\ndef cleanup_validation_alerts(sender, instance, **kwargs):\n    \"\"\"\n    When opinions are unpublished (probably permanently), we must be sure all alerts are handled. For now we just \\\n    resolve them.\n\n    :param sender: sender class\n    :param instance: object instance\n    :param kwargs: possibily moderator\n    \"\"\"\n    if instance.is_opinion:\n        moderator = kwargs.get('moderator', get_current_user())\n        Alert.objects.filter(scope='CONTENT', content=instance).update(moderator=moderator,\n                                                                       resolve_reason=_('Le billet a \u00e9t\u00e9 d\u00e9publi\u00e9.'),\n                                                                       solved_date=datetime.datetime.now(),\n                                                                       solved=True)\n\n\n@receiver(models.signals.post_delete, sender=Gallery)\n@receiver(models.signals.post_delete, sender=PublishableContent)\ndef log_content_deletion(sender, instance, **kwargs):\n    \"\"\"\n    When a content or gallery is deleted, this action is logged.\n    \"\"\"\n\n    logger = logging.getLogger(__name__)\n    current_user = get_current_user()\n\n    if current_user is None:\n        logger.info('%(instance_model)s #%(instance_pk)d (%(instance_slug)s) has been deleted. User not found.',\n                    {'instance_model': type(instance).__name__, 'instance_pk': instance.pk,\n                     'instance_slug': instance.slug})\n    else:\n        logger.info('%(instance_model)s #%(instance_pk)d (%(instance_slug)s) has been deleted '\n                    'by user #%(user_pk)d (%(username)s).', {'instance_model': type(instance).__name__,\n                                                             'instance_pk': instance.pk, 'instance_slug': instance.slug,\n                                                             'user_pk': current_user.pk,\n                                                             'username': current_user.username})\n", "path": "zds/tutorialv2/receivers.py"}]}