portier/source/concierge/signals.py

13 lines
550 B
Python
Raw Permalink Normal View History

from django.dispatch import receiver
from .models import Task
2024-04-01 16:27:31 +02:00
from config.signals_shared import stream_inactive
from config.models import Stream
@receiver(stream_inactive)
2024-04-01 16:27:31 +02:00
def delete_tasks_when_stream_inactive(sender, **kwargs):
# when a stream has become inactive, all related tasks which are created for the stream need to be deleted.
# we need to exclude the pull tasks, as they are not created for the stream.
stream = Stream.objects.get(stream=kwargs['stream'])
2024-04-01 16:27:31 +02:00
Task.objects.filter(stream=stream).exclude(type="pull").delete()