Merge branch 'fix-no-nested-sub-on-user-model' into 'master'

fix: no nested subscriptions on the user model

See merge request djangoldp-packages/djangoldp-notification!35
This commit is contained in:
Calum Mackervoy 2020-10-01 10:41:10 +00:00
commit fc67e73701
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import logging
import requests
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.mail import send_mail
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
@ -77,6 +78,10 @@ def create_nested_subscribers(sender, instance, created, **kwargs):
local = Model.resolve(instance.object.replace(settings.SITE_URL, ''))[0]
nested_fields = Model.get_meta(local, 'nested_fields', [])
# Don't create nested subscriptions for user model (Notification loop issue)
if local._meta.model_name == get_user_model()._meta.model_name:
return
for nested_field in nested_fields:
try:
field = local._meta.get_field(nested_field)