update: subscription for containers and resources
This commit is contained in:
parent
4d4b21e7e8
commit
d8ae6c1c75
@ -54,11 +54,12 @@ class Subscription(Model):
|
|||||||
# --- SUBSCRIPTION SYSTEM ---
|
# --- SUBSCRIPTION SYSTEM ---
|
||||||
@receiver(post_save, dispatch_uid="callback_notif")
|
@receiver(post_save, dispatch_uid="callback_notif")
|
||||||
def send_notification(sender, instance, **kwargs):
|
def send_notification(sender, instance, **kwargs):
|
||||||
if sender != Notification and isinstance(sender, Model):
|
if sender != Notification and issubclass(sender, Model):
|
||||||
threads = []
|
threads = []
|
||||||
url = settings.BASE_URL + Model.resource_id(instance) + '/'
|
urlContainer = settings.BASE_URL + Model.container_id(instance)
|
||||||
for subscription in Subscription.objects.filter(object=url):
|
urlResource = settings.BASE_URL + Model.resource_id(instance)
|
||||||
process = Thread(target=send_request, args=[subscription.inbox, url])
|
for subscription in Subscription.objects.filter(models.Q(object=urlResource)|models.Q(object=urlContainer)):
|
||||||
|
process = Thread(target=send_request, args=[subscription.inbox, urlResource])
|
||||||
process.start()
|
process.start()
|
||||||
threads.append(process)
|
threads.append(process)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user