2024-10-31 00:33:13 +08:00
|
|
|
from django.core.cache import cache
|
2024-05-10 23:15:29 +08:00
|
|
|
from django.db.models.signals import post_save
|
2024-10-31 00:33:13 +08:00
|
|
|
from django.dispatch import receiver
|
2024-05-10 23:15:29 +08:00
|
|
|
from notifications.models import Notification
|
|
|
|
|
|
|
|
# Template for running actions after user have paid for a subscription
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(post_save, sender=Notification)
|
|
|
|
def clear_cache_after_notification_update(sender, instance, **kwargs):
|
|
|
|
# Clear cache
|
2024-10-30 22:09:58 +08:00
|
|
|
cache.delete("notifications")
|
|
|
|
cache.delete(f"notifications_user:{instance.recipient.id}")
|