bugfix: model resource_id

This commit is contained in:
Matthieu Fesselier 2019-03-06 17:38:58 +07:00
parent 9694472c89
commit 6b6a5e1e8c
1 changed files with 3 additions and 3 deletions

View File

@ -47,16 +47,16 @@ class Subscription(models.Model):
def send_notification(sender, instance, **kwargs):
if (sender != Notification and sender != LogEntry):
threads = []
url = settings.BASE_URL + Model.get_absolute_url(instance) + '/'
url = settings.BASE_URL + Model.resource_id(instance) + '/'
for subscription in Subscription.objects.filter(object=url):
process = Thread(target=send_request, args=[subscription.inbox, url])
process.start()
threads.append(process)
def send_request(target, objectIri):
def send_request(target, object_iri):
try:
req=requests.post(target,
json={"@context":"https://cdn.happy-dev.fr/owl/hdcontext.jsonld",
"object": objectIri, "type": "update"},
"object": object_iri, "type": "update"},
headers={"Content-Type": "application/ld+json"})
except:
logging.error('Djangoldp_notifications: Error with request')