-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrige un bug lié aux demandes de mise en avant
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |