Skip to content
Snippets Groups Projects
Commit 4d5b6160 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier
Browse files

Merge branch 'subscription-field-delete-fix' into 'master'

bugfix: catching ObjectDoesNotExist in notifications listener

See merge request !34
parents 32f4c8fa 3e919022
No related branches found
No related tags found
1 merge request!34bugfix: catching ObjectDoesNotExist in notifications listener
Pipeline #7563 passed
...@@ -3,6 +3,7 @@ import logging ...@@ -3,6 +3,7 @@ import logging
import requests import requests
from django.conf import settings from django.conf import settings
from django.core.mail import send_mail from django.core.mail import send_mail
from django.core.exceptions import ObjectDoesNotExist
from django.db import models from django.db import models
from django.db.models.signals import post_save, post_delete from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver from django.dispatch import receiver
...@@ -123,11 +124,13 @@ def send_notification(sender, instance, **kwargs): ...@@ -123,11 +124,13 @@ def send_notification(sender, instance, **kwargs):
(not subscription.is_backlink or not kwargs.get("created")): (not subscription.is_backlink or not kwargs.get("created")):
# I may have configured to send the subscription to a foreign key # I may have configured to send the subscription to a foreign key
if subscription.field is not None and len(subscription.field) > 1: if subscription.field is not None and len(subscription.field) > 1:
instance = getattr(instance, subscription.field, instance)
try: try:
instance = getattr(instance, subscription.field, instance)
url_resource = settings.BASE_URL + Model.resource_id(instance) url_resource = settings.BASE_URL + Model.resource_id(instance)
except NoReverseMatch: except NoReverseMatch:
continue continue
except ObjectDoesNotExist:
continue
process = Thread(target=send_request, args=[subscription.inbox, url_resource, instance, process = Thread(target=send_request, args=[subscription.inbox, url_resource, instance,
kwargs.get("created", False)]) kwargs.get("created", False)])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment