Skip to content

Commit c660f1c

Browse files
jnovingerjeremystretch
authored andcommitted
Fixes #19702: add NotificationGroup.event_rules GenericRelation
The collector we use to notify users about dependent object that will be deleted does handle GFKs. However, a GenericRelation must be set up on the other end.
1 parent 334b45f commit c660f1c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

netbox/extras/models/notifications.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from functools import cached_property
22

33
from django.conf import settings
4-
from django.contrib.contenttypes.fields import GenericForeignKey
4+
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
55
from django.core.exceptions import ValidationError
66
from django.db import models
77
from django.urls import reverse
@@ -144,6 +144,12 @@ class NotificationGroup(ChangeLoggedModel):
144144
blank=True,
145145
related_name='notification_groups'
146146
)
147+
event_rules = GenericRelation(
148+
to='extras.EventRule',
149+
content_type_field='action_object_type',
150+
object_id_field='action_object_id',
151+
related_query_name='+'
152+
)
147153

148154
objects = RestrictedQuerySet.as_manager()
149155

0 commit comments

Comments
 (0)