Skip to content

Commit

Permalink
Corrige un bug lié aux demandes de mise en avant
Browse files Browse the repository at this point in the history
  • Loading branch information
Situphen committed Jul 19, 2024
1 parent 25f00df commit f7a9eec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions zds/featured/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class FeaturedConfig(AppConfig):
name = "zds.featured"

def ready(self):
from . import receivers # noqa
18 changes: 18 additions & 0 deletions zds/featured/receivers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.contrib.contenttypes.models import ContentType
from django.db.models.signals import pre_delete
from django.dispatch import receiver

from zds.featured.models import FeaturedRequested
from zds.forum.models import Topic
from zds.tutorialv2.models.database import PublishableContent


@receiver(pre_delete, sender=PublishableContent)
@receiver(pre_delete, sender=Topic)
def remove_requested_featured_at_content_object_deletion(sender, instance, **kwargs):
try:
FeaturedRequested.objects.get(
content_type=ContentType.objects.get_for_model(sender), object_id=instance.pk
).delete()
except FeaturedRequested.DoesNotExist:
pass

0 comments on commit f7a9eec

Please sign in to comment.