Skip to content

Commit

Permalink
feat(core): New signal for cleaning linked ticket items when the item…
Browse files Browse the repository at this point in the history
… is deleted

ref: #15 #248 #336 #376 #381
  • Loading branch information
jon-nfc committed Nov 7, 2024
1 parent 52b8450 commit 99ed0d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Empty file added app/core/signal/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions app/core/signal/ticket_linked_item_delete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

from django import dispatch
from django.dispatch import receiver

from core.models.ticket.ticket_linked_items import TicketLinkedItem

deleted_model = dispatch.Signal()


@receiver(deleted_model)
def signal_deleted_model(sender, item_id, item_type, **kwargs):
"""Clean up model TicketLinkedItems
a model was deleted, remove its link to any tickets it had.
"""

items = TicketLinkedItem.objects.filter(
item_type = item_type,
item = item_id
)

items.delete()

0 comments on commit 99ed0d1

Please sign in to comment.